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

[REBOL] Re: [none idiom found?] The best shortcut word for "not none?"

From: lmecir::mbox::vol::cz at: 5-Sep-2006 13:41

How about this implementation change, which is favoured by Cyphre, Gabriele and Anton, as it looks? (disadvantage - it is slower than the original due to the double search) switch1: func [ "Selects a choice and evaluates what follows it." [throw] value "Value to search for." cases [block!] "Block of cases to search." /default case [block!] "Default case if no others are found." /local blk ][ value: find cases value if value [value: find next value block!] either value [do first value] [if default [do case]] ] example: [ switch1 1 [2 4 6 ['even] 1 3 5 ['odd]] ] -Ladislav