Last active
December 16, 2015 02:59
-
-
Save timmc/5366403 to your computer and use it in GitHub Desktop.
This file contains 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 adhoc.core) | |
(defn arity | |
[n] | |
(let [args (repeatedly n gensym)] | |
`([~@args] (println "args" ~@args)))) | |
;; Seriously though, don't do this. | |
(defn magic | |
#=(arity 1) | |
#=(arity 3) | |
#=(arity 5)) | |
(comment | |
(magic :a :b :c) | |
; args :a :b :c | |
;= nil | |
(magic :a :b :c :d) | |
;! ArityException Wrong number of args (4) passed to: core$magic clojure.lang.AFn.throwArity (AFn.java:437) | |
(magic :a :b :c :d :e) | |
; args :a :b :c :d :e | |
;= nil | |
(source magic) | |
; (defn magic | |
; #=(arity 1) | |
; #=(arity 3) | |
; #=(arity 5)) | |
;= nil | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment