[REBOL] Re: Switch with refinements/hmmm!
From: media:quazart at: 2-Nov-2001 7:37
I was just about to write the Exact same algorithm... you beat me to the
reply... I'll have to improve my lightning reflexes a bit... ;-)
Joel, the advantage of supplying each condition is that you can then trap
any COMBINATION by itself... not just if a value is set by itself... in
some algo rithms you must know if all, some or one of them is set and also
which one... you can re-code the any/all combo exactly like your last
if/then but then it does take a little more stack space in your brain to
it before coding it...
But once its on "paper" I find that any/all combos are much easier to
maintain, simply because the expressions themselves are easier to extract
visually... especially when there are many conditions and that the algorythm
is more than the height of your screeen also consider the following...
all [refa refb refc print "condition a & b & c met"]
all [refa refb print "condition a & b met"]
print "nothing set"
now if you code that into if/else and the algorythm is quite long.... it
becomes quite a job to quickly see what is the quickest and best if/else
combo to build... there are many different possibilities and when you start
adding new conditions the algorithm just gets harder and harder to fix.
whereas the any and all combo still stays dead easy to maintain, cause you
just add one line.
But as you said, its just a question of fast to maintain vs fast to execute
vs fast to implement... I'm just trying to educate people into using
any/all which -sometimes- cuts my job a lot... just have to use it at the
----- Original Message -----
From: "Romano Paolo Tenca" <[rotenca--telvia--it]>
Sent: Thursday, November 01, 2001 7:20 PM
Subject: [REBOL] Re: Switch with refinements/hmmm!
> v: to-string replace/all reduce [ all[refa "a"] all [refb "b"] all [refc