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

[REBOL] Re: [REBOL]

From: joel:neely:fedex at: 31-Jan-2002 10:05

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-