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

rplaca


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

Syntax

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

Description

The 'rplaca' function destructively modifies the car 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))           ; make A with value (1 2 3)
(setq b '(1 2 3))           ; make B with value (1 2 3)
(setq c a)                  ; make C point to A's value
(rplaca a 'new)             ; returns (NEW 2 3)

(print a)                   ; prints (NEW 2 3)
                            ;   note that A is modified

(print b)                   ; prints (1 2 3)
                            ;   note that B is not modified

(print c)                   ; prints (NEW 2 3)
                            ;   note that C is modified too

(setq a '(1 2 3))           ; reset A to value (1 2 3)
(rplaca a '(the sub list))  ; returns ((THE SUB LIST) 2 3)
(rplaca '(1 2 3) 'more)     ; returns (MORE 2 3)

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

See the rplaca function in the XLISP 2.0 manual.

  Back to Top


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