You're viewing version 1.2.0 of function?. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

function?

clojure.test

  • (function? x)
Returns true if argument is a function or a symbol that resolves to
a function (not a macro).

1 Example top

  • user> (defn foo [] (println "foo"))
    #'user/foo
    
    user> (def bar "bar")
    #'user/bar
    
    user> (clojure.test/function? foo)
    true
    
    user> (clojure.test/function? bar)
    false
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/test.clj:403 top

(defn function?
  "Returns true if argument is a function or a symbol that resolves to
  a function (not a macro)."
  {:added "1.1"}
  [x]
  (if (symbol? x)
    (when-let [v (resolve x)]
      (when-let [value (get-possibly-unbound-var v)]
        (and (fn? value)
             (not (:macro (meta v))))))
    (fn? x)))
Vars in clojure.test/function?: and defn fn? meta not symbol? when-let
Used in 0 other vars

Comments top

No comments for function?. Log in to add a comment.