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))
A function that takes a single argument as input, such as. , is called a unary function. A function of two or more variables is considered to have a domain consisting of ordered pairs or tuples of argument values. The argument of a circular function is an angle.
In general a function that returns a function is the same as a function with an extra argument (possibly with lazier evaluation) so often there will not be a special name for this.
The identity function is a function which returns the same value, which was used as its argument. It is also called an identity relation or identity map or identity transformation.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With