Skip to content

Instantly share code, notes, and snippets.

@aria42
Forked from w01fe/fnk_examples.clj
Created October 1, 2012 21:29
Show Gist options
  • Save aria42/3814548 to your computer and use it in GitHub Desktop.
Save aria42/3814548 to your computer and use it in GitHub Desktop.
Bring on the fnk
(defnk foo [x y [s 1]]
(+ x (* y s)))
(foo {:x 2 :y 3 :s 2})
;; ==> 8
(foo {:x 2 :y 3})
;; 's' defaulted to 1
;; ==> 5
(foo {:x 2})
;; ==> (Exception. "Missing argument :y calling foo (got #{:x})")
(meta foo)
;; ==> {:req-ks #{:x :y}}
;; :opt-ks #{:s}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment