rplaca, rplacd

Gamma: Version 4.0
Prev |  | Next

# `rplaca`, `rplacd`

`rplaca`, `rplacd` -- replace the car and cdr of a list.

## Syntax

    rplaca (cons, s_exp)
    rplacd (cons, s_exp)

## Arguments

`list`

  A list element.

`s_exp`

  Any Gamma or Lisp expression.

## Returns

The `s_exp`, or nil on failure.

## Description

These functions destructively alter the form of a list. `rplaca` modifies the car of a list, effectively replacing the first element. `rplacd` modifies the cdr of a list, replacing the entire tail of the list. These functions have no meaning for non-lists. To entirely remove the tail of a list, replace the cdr of the list with nil.

## Example

        Gamma> x = list(1,2,3,4);
        (1 2 3 4)
        Gamma> rplaca(x,0);
        0
        Gamma> x;
        (0 2 3 4)
        Gamma> rplacd(x,list(7,8,9,10,11,12));
        (7 8 9 10 11 12)
        Gamma> x;
        (0 7 8 9 10 11 12)
        Gamma>

## See Also

`car, cdr`

Prev | Home | Next
`reverse` | Up | `shorten_array`

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