XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

rplacd


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

Syntax

(rplacd list expr)
list - the list to destructively modify
expr - the expression to replace the cdr of list
returns - the list node after updating the cdr

Description

The 'rplacd' function destructively modifies the cdr of 'list' and replaces it with the 'expr'. The destructive aspect of this operation means that the actual symbol value is used in the list-modifying operations, not a copy. 'list' must evaluate to a valid list.

An atom or NIL for 'list' will result in an error:

error: bad argument type

Examples

(setq a '(1 2 3))          ; set up A with (1 2 3)
(rplacd a 'new)            ; returns (1 . NEW)

(print a)                  ; prints (1 . NEW)
                           ;   note that A is modified

(rplacd a '(a new list))   ; returns (1 A NEW LIST)
(rplacd '(1 2 3) '(more))  ; returns (1 MORE)

(rplacd 'a 'b)             ; error: bad argument type
(rplacd NIL 'b)            ; error: bad argument type

See the rplacd function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next