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: 6-Sep-2006 13:38

Gabriele Santilli napsal(a):
> Hi Ladislav, > > On Tuesday, September 5, 2006, 1:41:57 PM, you wrote: > > LM> either value [do first value] [if default [do case]] > > I think you could write this as: > > do either value [first value] [case] > > with the assumption that case is none when the /default refinement > has not been specified. > > Regards, > Gabriele. >
OK, here is the improved version, which I am proposing to Carl too: REBOL [ Author: ["Ladislav Mecir" "Gabriele Santilli"] Purpose: "A SWITCH alternative, see example" ] switch1: func [ "Selects a choice and evaluates the first block that 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." ][ if value: find cases value [value: find next value block!] do either value [first value] [case] ] example: [ switch1 1 [2 4 6 ['even] 1 3 5 ['odd]] ]