Switch

switch


(macro switch (value case then ...cases) (...)) Takes a value to match against a list of (possible value, code to run)…

Note: Once the value is matched, it stops and doesn’t try any other values.

Parameters

  • value: value to match
  • case: first case
  • then: value when first case matches
  • ...cases: more (case, then)

Author

@SuperFola

Example

(switch 4
    1 (print "hello")
    2 (print "bye")
    12 (print "jackpot")
    (+ 1 4) (print "computation")
    _ (print "default"))