help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace element in list


From: tomas
Subject: Re: Replace element in list
Date: Mon, 2 Sep 2019 12:46:35 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Sep 02, 2019 at 12:41:08PM +0200, tomas@tuxteam.de wrote:
> On Mon, Sep 02, 2019 at 12:37:23PM +0200, tomas@tuxteam.de wrote:
> > On Mon, Sep 02, 2019 at 11:44:10AM +0200, Andreas Röhler wrote:
> > > Hi,
> > > 
> > > is there a recommended way to replace element x at index i of
> > > somelist  y by newelement?
> > 
> > Like this?
> > 
> >   scheme@(guile-user)> (define lst (list-copy '(fire water air earth)))
> >   scheme@(guile-user)> (list-set! lst 2 'mud)
> >   $3 = mud
> >   scheme@(guile-user)> lst
> >   $4 = (fire water mud earth)
> 
> Oops, sorry. Wrong language, wrong mailing list. Embarrasing.

In Emacs Lisp you could try:

  (setcar (nthcdr 3 foo) 'mud)

...but remember, you are leaving the functional sector ;-)

Cheers
-- t

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]