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

[REBOL] Re: Switch with refinements/hmmm!

From: rotenca:telvia:it at: 2-Nov-2001 1:20

Hi, Joel Neely
> reftree: func [/refa /refb /refc] [ > either refa > [either refb > [either refc > [print "all refs are set!"] > [print "ref A & B"]] > [either refc > [print "ref A & C"] > [print "ref A"]]] > [either refb > [either refc > [print "ref B & C"] > [print "ref B"]] > [either refc > [print "ref C"] > [print "NO refs"]]] > ] > > (which only evaluates each refinement once) it looks like a classic > case of "pay me now or pay me later". We either spend programmer > time to craft a faster process or we spend the cycles at run time.
Why not: v: to-string replace/all reduce [ all[refa "a"] all [refb "b"] all [refc "c"]] none "" print select ["" "no refs" "a" "refa" "b" "refb" "ab" "refa & b" "c" "refc" ac "refa & refc" "bc" "refb & refc" "abc" "refa & refb & refc"] v I find it more rebolesque. It is easy to mantain. It is fast. It is not C-like. It can be also more simple, but less readable: print select [[none none none] "no refs" [true none none] "a"...] reduce [ refa refb refc ]
> -jn-
--- Ciao Romano