User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:constantly [2019/07/14 17:00]
cl:functions:constantly [2019/07/18 14:00] (current)
Line 1: Line 1:
 +====== Function CONSTANTLY ======
 +
 +====Syntax====
 +  * **constantly** //value// → //​function//​
 +
 +====Arguments and Values====
 +  * //value// - an //​[[CL:​Glossary:​object]]//​.
 +  * //​function//​ - a //​[[CL:​Glossary:​function]]//​.
 +
 +====Description====
 +**constantly** returns a //​[[CL:​Glossary:​function]]//​ that accepts any number of arguments, that has no side-effects,​ and that always returns //value//.
 +
 +====Examples====
 +<​blockquote>​
 +([[CL:​Functions:​mapcar]] (constantly 3) '(a b c d)) <r>(3 3 3 3)</​r>​
 +([[CL:​Macros:​defmacro]] with-vars (vars &body forms) ​
 +  `(([[CL:​Macros:​lambda]] ,vars ,@forms) ,​@([[CL:​Functions:​mapcar]] (constantly [[CL:​Constant Variables:​[[CL:​Constant Variables:​nil]]]]) vars))) <​r>​WITH-VARS</​r>​
 +([[CL:​Functions:​macroexpand]] ​
 +  '​(with-vars (a b) 
 +     ​([[CL:​Macros:​setf]] a 3) 
 +     ​([[CL:​Macros:​setf]] b ([[CL:​Functions:​math-multiply|*]] a a))
 +     ​([[CL:​Functions:​list]] a b)))
 +<​r>​(([[CL:​Macros:​lambda|LAMBDA]] (A B) (SETF A 3) (SETF B ([[CL:​Functions:​math-multiply|*]] A A)) ([[CL:​Functions:​list|LIST]] A B)) NIL NIL), //​[[CL:​Glossary:​true]]//</​r>​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​identity|Function IDENTITY]]**
 +
 +====Notes====
 +**constantly** could be defined by:
 +
 +<​blockquote> ​
 +([[CL:​Macros:​defun]] constantly (object) #'​([[CL:​Symbols:​lambda]] (&rest arguments) object))
 +</​blockquote>​
 +
 +\issue{FUNCTION-COMPOSITION:​JAN89-X3J13}