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