Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 506 Bytes

README.md

File metadata and controls

32 lines (23 loc) · 506 Bytes

defmulti

WIP

is a simple attempt at bringing multiple dispatch to Carp (see also carp-lang/Carp#1072).

Because it is a mere macro, the functions only work in call position and can’t be used in higher-order functions.

Usage

(load "defmulti.carp")

(defmulti addr
  [] 0
  [x] (+ x 1)
  [x y (f +)] (f x y))

(defn main []
  (do
    (println* (addr))
    (println* (addr 1))
    (println* (addr 4 3))
    (println* (addr 4 3 (f -)))
    (println* (addr 4 3 *))))

Have fun!