Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

(Scheme) set! vs set-car!/set-cdr!

Name: Anonymous 2008-01-25 12:02

Hello there Scheme magicians, I walked across the desert from lands far away to seek your wisdom.
So, I have a list value some-list set to () and I need to change it to, say, (0 1 2 3).  I can't use set! for obvious reasons (set! is like SETQ, a special form and not a first-class procedure) and I can't use set-car!/set-cdr! either because they want a mutable pair.  How do I assigned to a list variable, /prog/?

Name: Anonymous 2008-01-25 13:23

>>11
Yes, you're looking to bind the variable to a different value. You're not even attempting to mutate a list in this example. You're binding that variable to the start of a completely different chain of pairs. The question is, why do you even want to do this? What makes (lol-side-effects list-to-be-changed) better than (set! list-to-be-changed (function-returning-a-new-value-for-the-previous-variable-to-be-bound-to))?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List