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

[REBOL] Re: Reverse select?

From: tim-johnsons:web at: 7-Aug-2007 15:18

On Tuesday 07 August 2007, Kai Peters wrote:
> Given > > states: [ "AZ" "Arizona" "WY" "Wyoming" "FL" "Florida" ] > > How can I 'reverse select', i.e. find "WY" given "Wyoming" ? > > TIA, > Kai
Hi Kai: I use this: before: func[ "Returns item *before* 'key in 'data, if found." data[series!] key[any-type!] /local found][ either found: find data key[pick data (index? found) - 1][none] ] NOTE: this code was slight altered from my own library, since I use 'def instead of 'fun (local variables generated automatically)