Skip to content

Instantly share code, notes, and snippets.

@pingles
Created May 4, 2011 19:38
Show Gist options
  • Save pingles/955859 to your computer and use it in GitHub Desktop.
Save pingles/955859 to your computer and use it in GitHub Desktop.
Example using defnk to take optional params
(ns defnk-example
(:use [clojure.contrib.def :only (defnk)]))
(defnk some-fn
[x y :opt1 :a :opt2 :b]
(str "x: " x " opt1: " opt1 " opt2: " opt2))
defnk-example> (some-fn "x" "y" :opt1 5 :opt2 10)
"x: x opt1: 5 opt2: 10"
defnk-example> (some-fn "x" "y")
"x: x opt1: 0 opt2: 1"
defnk-example> (apply some-fn "x" "y" [:opt1 :b])
"x: x opt1: :b opt2: :b"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment