I usually use identity as a predicate for functions such as filter,
drop-while, take-while, etc.

Consider this silly example: imagine you had an operation that fetches
stuff from a resource (DB, network, etc.) and that upon failing it
returns nil. Additionally, imagine that you're interested in running
this operation for several resources and keeping those values which
didn't fail. You can do so with identity:

user=> (defn my-operation-that-might-fail [x]
  (if (= x "foo") x nil))
#'user/my-operation-that-might-fail
user=> (def some-values ["bar" "foo" "baz"])
#'user/some-values
user=> (filter identity (map your-pred some-values))
("foo")
user=>

and you have your single operation that didn't fail.

My 0.5cts.

U

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to