[Top][All Lists]

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

Re: [Chicken-users] Replace an element in a list

From: Dan Leslie
Subject: Re: [Chicken-users] Replace an element in a list
Date: Sat, 13 Dec 2014 18:45:57 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0


Yes, my way is the way not to do it; thanks to my reading comprehension failure. ;)


On 14-12-13 06:44 PM, John Cowan wrote:
Bahman Movaqar scripsit:

What is the idiomatic way of replacing the nth element in a list
*without* mutating the list? Is the combination of "take" and
"take-right" the right way to do it?
Yes, that's how I'd do it.

Daniel Leslie scripsit:

There are setters for car and cdr, so let's say you're at a position where
you want to replace the head of a list, you can then just do:

(set! (car some-list) some-value)
That's how you do it when you *do* want to mutate the list, or you can
use list-set! if you have it (as R7RS does).

reply via email to

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