liveBook · Manning

Fn?

As explained in Clojure: The Essential Reference

fn? is a Clojure predicate that returns true when its argument is a Clojure function.

Use `fn?` to check whether a value is a Clojure function. It returns `true` for a function and `false` for a non-function value. Functions created with `fn` are first-class values: they can be bound locally or passed as arguments. section 2.1.2

Checking function values

```clojure (fn? (fn [x] x)) ; true (fn? (partial + 1)) ; true (fn? 42) ; false ``` `partial` generates a new function, so its result can be checked just like a function written with `fn`. section 2.1.2 section 2.2.8

How Clojure: The Essential Reference covers it

How deep it goes
Defines the predicate's true-or-false behavior but does not detail its implementation or classify other callable values.
Examples
Checks an fn expression, a partial application, and a number for function status.
What it assumes
Assumes basic Clojure expression syntax and introduces functions created with fn.
What you can do after
Evaluate/understand it to distinguish Clojure function values from non-function values.
How it connects
Connects function checks to fn-created functions and functions generated by partial.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clojure: The Essential Reference. The section links point to the parts of the book it draws on.