User Tools


Differences

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

Link to this comparison view

cl:functions:cons [2019/07/14 17:00]
cl:functions:cons [2019/10/19 17:00] (current)
Line 1: Line 1:
 +====== Function CONS ======
  
 +====Syntax====
 +  * **cons** //​object-1//​ //​object-2//​ → //cons//
 +
 +====Arguments and values==== ​
 +  * //​object-1//​ - an //​[[CL:​Glossary:​object]]//​.
 +  * //​object-2//​ - an //​[[CL:​Glossary:​object]]//​.
 +  * //cons// - a //​[[CL:​Glossary:​cons]]//​.
 +
 +====Description====
 +Creates a //​[[CL:​Glossary:​fresh]]//​ //​[[CL:​Glossary:​cons]]//,​ the //​[[CL:​Glossary:​car]]//​ of which is //​object-1//​ and the //​[[CL:​Glossary:​cdr]]//​ of which is //​object-2//​.
 +
 +====Examples====
 +<​blockquote>​
 +(cons 1 2) <r>(1 . 2)</​r>​
 +(cons 1 [[CL:​Constant Variable:​nil]]) <​r>​(1)</​r>​
 +(cons [[CL:​Constant Variable:​nil]] 2) <​r>​([[CL:​Constant Variable:​nil|NIL]] . 2)</​r>​
 +(cons [[CL:​Constant Variable:​nil]] [[CL:​Constant Variable:​nil]]) <​r>​([[CL:​Constant Variable:​nil|NIL]])</​r>​
 +(cons 1 (cons 2 (cons 3 (cons 4 [[CL:​Constant Variable:​nil]])))) <r>(1 2 3 4)</​r>​
 +(cons 'a 'b) <r>(A . B)</​r>​
 +(cons 'a (cons 'b (cons 'c '()))) <r>(A B C)</​r>​
 +(cons 'a '(b c d)) <r>(A B C D)</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See also====
 +**[[CL:​Functions:​list|Function LIST]]**
 +
 +====Example Implementation====
 +To be done.
 +
 +====Notes====
 +If //​object-2//​ is a //​[[CL:​Glossary:​list]]//,​ **cons** can be thought of as producing a new //​[[CL:​Glossary:​list]]//​ which is like it but has //​object-1//​ prepended.