1.3.0 permalink Arrow_down_16x16

identity

clojure.core

  • (identity x)
Returns its argument.

6 Examples top

  • user=> (identity 4)
    4
  • user=> (filter identity [1 2 3 nil 4 false true 1234])
    (1 2 3 4 true 1234)
  • user=> (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)
    
  • user=> (partition-by identity (sort "abcdaabccc"))
    ((\a \a \a) (\b \b) (\c \c \c \c) (\d))
    
  • user=> (map first (partition-by identity [1 1 2 3 3 1 1 5 5]))
    (1 2 3 1 5)
  • user=> (group-by identity "abracadabra")
    {\a [\a \a \a \a \a], \b [\b \b], \r [\r \r], \c [\c], \d [\d]}
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1350 top

(defn identity
  "Returns its argument."
  {:added "1.0"
   :static true}
  [x] x)
Vars in clojure.core/identity:
Used in 0 other vars

Comments top

No comments for identity. Log in to add a comment.