15 minutes ago, Neil Van Dyke wrote: > Eli Barzilay wrote at 10/08/2010 10:57 PM: > > Here's a much shorter version that doesn't require goto emulation, > > Nice. On principle, I was going to trouble to avoid redundant > tests, as well as give the compiler a single optimization-friendly > "case" form, followed by tail calls. In practice, I guess any > runtime performance difference would likely be in the noise.
Well, if you want to be picky, then my version is quadratic in the size of the lists it `memq's over -- but that could be addressed together with your point by doing something like converting (cas-cad-e foo [(a b c) bar] [(x y z) baz]) to (let ([t (assq foo '([a . 1] [b . 1] [c . 1] [x . 2] [y . 2] [z . 2]))]) (when (<= t 2) (when (<= t 1) bar) baz)) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users