Skip to content
Turtle Kitty edited this page Aug 9, 2015 · 2 revisions

case

This operator is a pattern-matching conditional.

(fun foo (x) 
    (case x
        (0) 'foo
        (1) 'bar
        (2 5) (+ x x x)
        default: (* x x)))
    
(foo 0) -> 'foo
(foo 1) -> 'bar
(foo 2) -> 6
(foo 4) -> 16
(foo 5) -> 15
Clone this wiki locally