cons

AutoCad AutoLISP Functions

 
cons
 
 
 

Adds an element to the beginning of a list, or constructs a dotted list

(cons new-first-element list-or-atom) 

Arguments

new-first-element

Element to be added to the beginning of a list. This element can be an atom or a list.

list-or-atom

A list or an atom.

Return Values

The value returned depends on the data type of list-or-atom. If list-or-atom is a list, cons returns that list with new-first-element added as the first item in the list. If list-or-atom is an atom, cons returns a dotted pair consisting of new-first-element and list-or-atom.

Examples

Command: (cons 'a '(b c d))

(A B C D)

Command: (cons '(a) '(b c d))

((A) B C D)

Command: (cons 'a 2)

(A . 2)

See Also