Skip to content

Instantly share code, notes, and snippets.

@lokori
Created December 16, 2015 08:02
Show Gist options
  • Save lokori/be67c0d81f5ce39868a8 to your computer and use it in GitHub Desktop.
Save lokori/be67c0d81f5ce39868a8 to your computer and use it in GitHub Desktop.
clojure function arity reflector
(defn no-args?
"Returns true if f is a sym/var of a function with no arguments. False otherwise."
[f]
(cond (and
(seq? f)
(= 'fn* (first f)))
(empty? (second f))
(symbol? f)
(= '([]) (:arglists (meta (resolve f))))
(var? f)
(= '([]) (:arglists (meta f)))
(clojure.test/function? f)
(= ('[]) (:arglists (meta f))))
(true? true) false))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment