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

[REBOL] Re: Switch with refinements/hmmm!

From: media:quazart at: 2-Nov-2001 7:37

Hey Romano, 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 see 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... any [ all [refa refb refc print "condition a & b & c met"] all [refa refb print "condition a & b met"] all [refc] 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 right moment... ciao! -Max ----- Original Message ----- From: "Romano Paolo Tenca" <[rotenca--telvia--it]> To: <[rebol-list--rebol--com]> 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
c ]]