Function that just returns its argument?

common-lisp

Solution

Take a look at `identity`:

Function IDENTITY

Syntax:

identity object ⇒ object

Arguments and Values:

object—an object.

Description:

Returns its argument object.

BTW, the ANSI CL standard specifies almost a thousand symbols. You cannot learn them all overnight. Also, Lisp is a language with a rich history, so if you want something "general purpose", chances are that either the language provides that, or some (semi-)standard library does.

Ask away! Do not reinvent the bike.

Problem

In Common Lisp, is there a function in the standard library that simply returns the parameter given (i.e. doesn't manipulate the data)? This function would be equivalent to `(lambda (x) x)`. I'm looking to use it as the default for an optional parameter. For example, such a function would replace `(lambda (x) x)` in: ``` (defun some-function (value &optional (transformation (lambda (x) x))) (other-function (funcall transformation value)) ```

Original source