XLISP cons

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# cons

Type: | - | function (subr)
Source: | - | xllist.c

## Syntax

(cons expr-car expr-cdr)
  expr-car - an expression
  expr-cdr - an expression
  returns - the new list

## Description

The 'cons' function takes two expressions and constructs a new list from them. If the 'expr-cdr' is not a list, then the result will be a 'dotted-pair'.

## Examples

    (cons 'a 'b)           ; returns (A . B)
    (cons 'a nil)          ; returns (A)
    (cons 'a '(b))         ; returns (A B)
    (cons '(a b) '(c d))   ; returns ((A B) C D)
    (cons '(a b) 'c)       ; returns ((A B) . C)
    (cons (- 4 3) '(2 3))  ; returns (1 2 3)

See the cons function in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference