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

2003-12-23 Thread Ladislav Mecir
Hi Pat, >What is the meaning of thro? >I have seen it here and there but never quite understood its purpose. > >Regards >Patrick > > >- Original Message - >From: "Ladislav Mecir" > > > >>yes, it is useful. The following improvement uses the [throw] attribute >>to make the behaviour of

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

2003-12-23 Thread patrick.philipot
Hi List, What is the meaning of thro? I have seen it here and there but never quite understood its purpose. Regards Patrick - Original Message - From: "Ladislav Mecir" > yes, it is useful. The following improvement uses the [throw] attribute > to make the behaviour of the function mo

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

2003-12-23 Thread Gregg Irwin
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

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

2003-12-23 Thread Ladislav Mecir
Hi Alain, >Here is a function for only 1 condition but 3 cases : if it can be >useful to anyone > >trif: func [ > > >... > > >; example: >print trif request "give an answer" ["yes"]["no"]["cancel"] > >by the way, >is it good that "not none" equals "true" ? > >Alain Goyé. > > yes, it is us

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

2003-12-23 Thread Alain Goyé
Hello all from a newcomer to this list, Here is a function for only 1 condition but 3 cases : if it can be useful to anyone trif: func [ condition iftrue [block!] iffalse [block!] ifnone [block!] ] [ do either condition [ iftrue ] [ either none? condition

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

2003-12-20 Thread Anton Rolls
Oops, should be > 3 cases. Anton. > do select reduce [...] is only better in code-size > for > ~8 cases. -- To unsubscribe from this list, just send an email to [EMAIL PROTECTED] with unsubscribe as the subject.

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

2003-12-20 Thread Anton Rolls
Actually, I will change it to your suggestion for this situation, because with only two/three cases to select from, it is more efficient code. do select reduce [...] is only better in code-size for > ~8 cases. Anton. > Hi Anton, > > On Wednesday, December 17, 2003, 3:00:06 PM, you wrote: > > A

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

2003-12-19 Thread Joel Neely
Hi, Maxim, There's more to the story, although YMMV... Maxim Olivier-Adlhoch wrote: > > describe: func [x [integer!] y [integer!]] [ > switch true compose [ > (x = 1) ["X is one"] > (y = 1) ["Y is one"] > (x = 2) ["X is two"] > (y =

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

2003-12-19 Thread Maxim Olivier-Adlhoch
sorry for being late, but note that this works, straight out of the box: describe: func [x [integer!] y [integer!]] [ switch true compose [ (x = 1) ["X is one"] (y = 1) ["Y is one"] (x = 2) ["X is two"] (y = 2) ["Y is two"]

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

2003-12-18 Thread Anton Rolls
Thanks Joel, I think this is just what I need. I don't think pif is a good name for it, though, it reminds me of obscure unix commands, not very rebolish. But what is a good name? Perhaps something like "reselect" (because it's a bit like a select reduce, but since that's not strictly true, then t

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

2003-12-18 Thread Gabriele Santilli
Hi Anton, On Wednesday, December 17, 2003, 3:00:06 PM, you wrote: AR> do select reduce [ AR> event/shift [...] AR> event/control [...] AR> true [...] ; default AR> ] true any [ if event/shift [... true] if event/control [... true] (..

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

2003-12-17 Thread Joel Neely
Hi, Anton, Set the WayBack machine to 2000... ;-) Anton Rolls wrote: > I yearn (want), occasionally, a kind of any/switch-like > flow-control function... Some years ago we had a long discussion about generalizing IF on the list, and kicked around various options/versions. The copy I could lay