cons

cons -- constructs a cons cell.

Syntax

cons (car_exp, cdr_exp)

		

Arguments

car_exp

Any Gamma or Lisp expression.

cdr_exp

Any Gamma or Lisp expression.

Returns

A list whose car is car_exp and whose cdr is cdr_exp.

Description

This function constructs a list whose car and cdr are car_exp and cdr_exp respectively. This construction is also known as a cons cell. If the cdr_exp is a list, this has the effect of increasing the list by one member, that is, adding the car_exp to the beginning of the cdr_exp.

Example

    Gamma> a = list(2,3,4);
    (2 3 4)
    Gamma> b = 5;
    5
    Gamma> cons(b,a);
    (5 2 3 4)
    Gamma> cons(a,b);
    ((2 3 4) . 5)
    Gamma> cons(5,nil);
    (5)
    Gamma> 
    		

See the Start a Process section of the Common Functions for Any Progam chapter (Tutorial Two), or the Photon: Interpolator Options Widgets section of the History Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

See Also

Data Types and Predicates

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.