Skip to content

Instantly share code, notes, and snippets.

@w01fe
Forked from aria42/fnk_examples.clj
Created October 2, 2012 00:43
Show Gist options
  • Save w01fe/3815504 to your computer and use it in GitHub Desktop.
Save w01fe/3815504 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
;; 's' defaults to 1
(foo {:x 2 :y 3})
; ==> 5
(foo {:x 2})
; ==> (Exception. "Missing argument :y ...")
(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