Adds an element to the beginning of a list, or constructs a dotted list
Supported Platforms: Windows, Mac OS, and Web
Signature
(cons new-first-element list-or-atom)
- new-first-element
-
Type: Integer, Real, String, List, T, or nil
Element to be added to the beginning of a list. This element can be an atom or a list.
- list-or-atom
-
Type: Integer, Real, String, List, or T
A list or an atom.
Return Values
Type: List
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
(cons 'a '(b c d)) (A B C D) (cons '(a) '(b c d)) ((A) B C D) (cons 'a 2) (A . 2)