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 12:16

>>2-4
(define my-set!
  (lambda (x y)
    (set! x y)))

(define dong (list 6 7 8))    ; dong is (6 7 8)
(my-set! dong (list 0 1 2 3)) ; after this dong is still (6 7 8)

And if I change set! to set-cdr! I get (6 0 1 2 3), but I want to be able to change lists with only 1 assignment procedure which also could handle ().  Is it possible?//

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