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

[REBOL] Re: a new switch-like flow-control function

From: greggirwin:mindspring at: 23-Dec-2003 9:21

AG> Hello all from a newcomer to this list, Welcome Alain! AG> Here is a function for only 1 condition but 3 cases : if it can be AG> useful to anyone AG> trif: func [ AG> condition AG> iftrue [block!] AG> iffalse [block!] AG> ifnone [block!] For more standard REBOL style, you might consider using hyphens to separate words. e.g. if-true [block!] if-false [block!] if-none [block!] You could also use PICK in place of a second either: trif: func [ condition if-true [block!] if-false [block!] if-none [block!] ] [ do either none? condition [if-none] [pick [if-true if-false] condition] ] Using PICK this way isn't always the clearest choice, but sometimes it can be quite handy. AG> by the way, AG> is it good that "not none" equals "true" ? I think so. What else would you have it return? Thanks for posting! -- Gregg