[REBOL] Re: ALL and ANY words
From: carl:cybercraft at: 2-Feb-2003 1:19
Hi Philippe,
On 04-Jan-80, Philippe Oehler wrote:
> The All word is often used by some rebolwriters in this case : all
> [select nam word find text search-text , etc..].. I mean : it is
> used with more than 2 parameter, and often with not always a TRUE OR
> FALSE' return (it seems...). It is done very often by Carl ..
> Personnally, I used 'all and 'any , in those cases : all [(a > 0)(b
>> 0)], i.e.
> It seems that the 'all and 'any word are used in a area that is
> different.. Is it like the C langage when FALSE is zero and all
> other cases TRUE.. I understand that a function like SELECT (taken
> as exemple above) could return true of false.. It's not the point..
> I just want to know if the values that 'all evaluate can be other
> than true or false..
Yes, the results can be other than true or false (or none). With ALL,
each expression in the block is evaluated in turn, unless one returns
FALSE or NONE, at which point the rest of the expressions are
ignored.
ie, here no NONE or FALSE values are returned...
>> all [print "a" 1 = 1 print "b" 2 = 2 print "c" 3 = 3]
a
b
c
== true
but here the 2 = 3 is false, so that's as far as the evaluation
gets...
>> all [print "a" 1 = 1 print "b" 2 = 3 print "c" 3 = 3]
a
b
== none
With ANY, the block is evaluated until the first true (or non-none or
non-false, if you will) is returned, at which point the rest of the
evaluations are skipped.
ie, here nothing is true...
>> any [1 = 2 3 = 4 5 = 6]
== none
while here the print "a" is considered true so evaluation stops there
and doesn't reach the print "b"...
>> any [1 = 2 3 = 4 print "a" 5 = 6 print "b"]
a
HTH.
--
Carl Read