Created
July 14, 2012 13:55
-
-
Save bkyrlach/3111475 to your computer and use it in GitHub Desktop.
Understanding Clojure functions...
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
| (defn foo | |
| ([a b] (println "bar")) | |
| ([a b c] (println "foobar"))) | |
| ;#'user/foo | |
| (foo 1 2) | |
| ;bar | |
| ;nil | |
| (foo 1 2 3) | |
| ;foobar | |
| ;nil | |
| (foo 1) | |
| ;ArityException Wrong number of args (1) passed to: core$foo clojure.lang.AFn.throwArity (AFn.java:437) | |
| (foo 1 2 3 4) | |
| ;ArityException Wrong number of args (4) passed to: core$foo clojure.lang.AFn.throwArity (AFn.java:437) | |
| (if false (foo 1 2) (foo 1)) | |
| ;ArityException Wrong number of args (1) passed to: core$foo clojure.lang.AFn.throwArity (AFn.java:437) | |
| (defn bar [runme] (if runme (foo 1 2) (foo 1))) | |
| ;#'user/bar | |
| (bar true) | |
| ;bar | |
| ;nil | |
| (bar false) | |
| ;ArityException Wrong number of args (1) passed to: core$foo clojure.lang.AFn.throwArity (AFn.java:437) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment