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-27 20:02

>>19
it can actually be done with set-cdr! if l was not empty, as noted above, but they work with pairs and not lists so they won't work with () which is a list but not a pair.

Welcome to MzScheme v371 [3m], Copyright (c) 2004-2007 PLT Scheme Inc.
(list? '())
#t
(pair? '())
#f

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