Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

rplaca

rplaca

type: function (subr) 
location: built-in
source file: xllist.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

(rplaca <list> <expr> )
        <list>          -       the list to DESTRUCTIVELY modify
        <expr>          -       the expression to replace CAR of <list>

DESCRIPTION

RPLACA 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.

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


Go to the first, previous, next, last section, table of contents.