You're viewing version 1.2.0 of ifn?. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (ifn? x)
Returns true if x implements IFn. Note that many data structures
(e.g. sets and maps) implement IFn

1 Example top

  • ;; An anonymous function is a function as you'd expect
    user=> (ifn? #("my anonymous function"))
    true
    
    ;; Is a vector a function?
    user=> (ifn? [1 2 3])
    true
    
    ;; Sure is, lets call it.
    user=> ([1 2 3] 0)
    1
    
    ;; Maps and sets are functions, too.
    
    ;; a number is definitely not a function
    user=> (ifn? 1)
    false
    
    ;; but a symbol is
    user=> (ifn? 'foo)
    true
    
    ;; and so is a keyword
    user=> (ifn? :foo)
    true
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/fn?

    Returns true if x implements Fn, i.e. is an object created via fn.

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:4983 top

(defn ifn?
  "Returns true if x implements IFn. Note that many data structures
  (e.g. sets and maps) implement IFn"
  {:added "1.0"}
  [x] (instance? clojure.lang.IFn x))
Vars in clojure.core/ifn?: defn instance?

Comments top

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