store/[org.clojure/clojure "1.8.0"] clj::clojure.core/identity

Official Documentation

Add notes
Arities
==================================================
   [x]

Docstring
==================================================
  Returns its argument.

Source

(defn identity
  "Returns its argument."
  {:added "1.0"
   :static true}
  [x] x)

Example 1

Edit
(filter identity [1 2 3 nil 4 false true 1234])
;; => (1 2 3 4 true 1234)

Example 2

Edit
(map first (partition-by identity [1 1 2 3 3 1 1 5 5]))
;; => (1 2 3 1 5)

Example 3

Edit
(identity 4)
;; => 4

Example 4

Edit
(map #(%1 %2) (cycle [inc identity]) [1 2 3 4 5 6 7 8 9 10])
;; => (2 2 4 4 6 6 8 8 10 10)

Example 5

Edit
(partition-by identity (sort "abcdaabccc"))
;; => ((\a \a \a) (\b \b) (\c \c \c \c) (\d))

Example 6

Edit
(group-by identity "abracadabra")
;; => {\a [\a \a \a \a \a], \b [\b \b], \r [\r \r], \c [\c], \d [\d]}

Uses on crossclj