Created
May 4, 2011 19:38
-
-
Save pingles/955859 to your computer and use it in GitHub Desktop.
Example using defnk to take optional params
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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