Skip to content

Instantly share code, notes, and snippets.

@w01fe
Created September 28, 2012 23:32
Show Gist options
  • Save w01fe/3802606 to your computer and use it in GitHub Desktop.
Save w01fe/3802606 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})
;; ==> 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