Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search


From: riusa:email:it at: 1-Feb-2002 0:19

I found some solutions, I wish to propose them to you: - 1 ------------------ month-list: [gen jan feb feb mar mar apr apr mag may giu jun lug jul ago aug set sep ott oct nov nov dic dec] select month-list 'feb select month-list 'giu Of course, it is good only for ITALIAN->ENGLISH (for reverse, we should reverse the order of the items...). - 2 ------------------ date1: [gen feb mar apr mag giu lug ago set ott nov dic] date2: [jan feb mar apr may jun jul aug sep oct nov dec] idx: index? find date1 'gen date2/:idx * Advantage: reverse is ok... idx: index? find date2 'gen date1/:idx - 3 ------------------ -----Messaggio originale----- Da: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]Per conto di Joel Neely Inviato: Thursday, January 31, 2002 5:05 PM A: [rebol-list--rebol--com] Oggetto: [REBOL] Re: [REBOL] Hi, Alessandro, Pardon the fragmentary answer, but my Italian is non-existent! ;-) [riusa--email--it] wrote:
> Hi, > > can someone tell me if exists a function (or similar) to map a serie > over another one? > > E.G.: > (used to translate the month names from italian to english): > ['GEN 'FEB 'MAR 'APR 'MAG ] --> ['JAN 'FEB' 'MAR 'APR 'MAY] >
The general strategy is to use a block that alternatest the from and "to" values, then use SELECT to obtain the corresponding value for a specific input. In this case (perhaps?) we can "cheat" and decide only to translate the cases that are different, and give back the input if there's no translation specified. Thus, for example: month-it-en: func [it-month [string!] /local en-month] [ either none? en-month: select/skip [ "GEN" "JAN" "MAG" "MAY" ] it-month 2 [ it-month ][ first en-month ] ] which behaves as follows:
>> month-it-en "GEN" == "JAN" >> month-it-en "FEB" == "FEB" >> month-it-en "MAR" == "MAR" >> month-it-en "APR" == "APR" >> month-it-en "MAG" == "MAY" >> month-it-en "foo" == "foo"
You might want to use a fully-populated block of values (paired values, actually) and let the lookup-failure value be some other indication, such as the original value wrapped in question marks... HTH! -jn- -- To unsubscribe from this list, please send an email to [rebol-request--rebol--com] with "unsubscribe" in the subject, without the quotes. -- Prendi GRATIS l'email universale che... risparmia: Sponsor: Obiettivo Laurea? Scopri la formula vincente per la preparazione dei tui esami universitari! Per informazioni Clicca qui: