From: Chester Wong
Subject: What function do I use?
Date: 
Message-ID: <3335d827.97456775@news.cc.columbia.edu>
Hi.  I forgot what function I would use to modify existing data in memory.
For example:

(setf x '( (1 2 3) (a b c) ))
(setf y x)

now y is just a pointer to the data that x points to, right?  Well, what
function would allow me to swap, say, "1" and "a"??  I tried to use
replace...but it didn't work.  Thanks.

Chester

From: Barry Margolin
Subject: Re: What function do I use?
Date: 
Message-ID: <5h50lm$f8j@pasilla.bbnplanet.com>
In article <·················@news.cc.columbia.edu>,
Chester Wong <·····@columbia.edu> wrote:
>Hi.  I forgot what function I would use to modify existing data in memory.

(setf <place> <value>) is the general function for modifying what's in
<place>.

>For example:
>
>(setf x '( (1 2 3) (a b c) ))
>(setf y x)
>
>now y is just a pointer to the data that x points to, right?  Well, what
>function would allow me to swap, say, "1" and "a"??  I tried to use
>replace...but it didn't work.  Thanks.

ROTATEF with two arguments will swap the the contents of the two places:

(rotatef (first (first x)) (first (second x)))

Functions for replacing in particular data types include RPLACA and RPLACD
(for conses), SUBSTITUTE (for sequences), include NSUBST (for trees).
-- 
Barry Margolin
BBN Corporation, Cambridge, MA
······@bbnplanet.com
(BBN customers, call (800) 632-7638 option 1 for support)
From: Adam Jenkins
Subject: Re: What function do I use?
Date: 
Message-ID: <yzhu3m1dqid.fsf@boogah.cs.umass.edu>
·····@columbia.edu (Chester Wong) writes:

> 
> Hi.  I forgot what function I would use to modify existing data in memory.
> For example:
> 
> (setf x '( (1 2 3) (a b c) ))
> (setf y x)
> 
> now y is just a pointer to the data that x points to, right?  Well, what
> function would allow me to swap, say, "1" and "a"??  I tried to use
> replace...but it didn't work.  Thanks.
> 
> Chester

You could do

USER(9): (setf x '( (1 2 3) (a b c) ))
((1 2 3) (A B C))
USER(10): (rotatef (caar x) (caadr x))
NIL
USER(11): x
((A 2 3) (1 B C))
USER(12): 


-- 
Adam P. Jenkins
···············@cs.umass.edu

University of Massachusetts/Amherst
Office Number: (413) 545-3506
From: Rainer Joswig
Subject: Re: What function do I use?
Date: 
Message-ID: <joswig-ya023180002403970715390001@news.lavielle.com>
In article <·················@news.cc.columbia.edu>, ·····@columbia.edu
(Chester Wong) wrote:

> Hi.  I forgot what function I would use to modify existing data in memory.
> For example:
> 
> (setf x '( (1 2 3) (a b c) ))
> (setf y x)
> 
> now y is just a pointer to the data that x points to, right?  Well, what
> function would allow me to swap, say, "1" and "a"??  I tried to use
> replace...but it didn't work.  Thanks.

(rotatef (first (first x))
         (first (second x)))

-- 
http://www.lavielle.com/~joswig/