Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 5504 days ago | link | parent

Or add a sym to the case itself.

    (case x (in 1 3 5) 'odd ..)
Harder to implement, though.


1 point by aw 5504 days ago | link

That's a clever idea, I think I probably would use a macro that let me check a value against a series of expressions (perhaps using some form of currying). I don't think I'd call it "case" though :-)

-----

1 point by akkartik 5504 days ago | link

How about allowing cases to be functions?

  (case x
    [in _ '(1 3 5)] 'odd
    ..)

-----

1 point by twilightsentry 5503 days ago | link

I've got a macro like that, which I call 'test. The problem with combining that and 'case is distinguishing functions and constants before the cases are eval'ed.

  (mac testlet (var expr . args)
    (letf ex (args)
           (if cdr.args
               `(if (,car.args ,var) ,cadr.args
                    ,(args cddr.args))
               car.xs)
      `(let ,var ,expr ,(ex args))))
Anyway, I'll probably just define 'casein as aw and rntz suggested.

-----