The line below shows the first element which is not nil.

(message "%s" (cl-some  #'(lambda (x) x) '(nil nil "hello" nil)))
;; Output: hello

Is there a built-in function which is equivalent to (lambda (x) x)?

1 Answer 1


identity is a built-in function that returns its argument unchanged:

(identity ARG)
  • Thanks. What should I do to find a built-in function easily? I searched a lot but could not find it.
    – Zheng Qu
    Feb 2, 2020 at 15:28
  • 1
    I don't know of any magic formula for finding such things, but in this case, it's helpful if you know other functional programming languages as well, as it's common for them to support some sort of an identity function. Feb 2, 2020 at 16:20
  • 1
    To discover the existence of a function you can match either its doc or its name. Matching the doc means you can sometimes use words that might be used to describe the function. The apropos commands are your friend. See, e.g., apropos and apropos-documentation. For this function, "identity" is the typical name and describer, AFAIK.
    – Drew
    Feb 2, 2020 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.