/ Published in: Scheme
set-car! and set-cdr! change a list 'in-place'.
But, if you like the pointer metaphore... you could use macro's
instead of procedures...
stupidly simple example...
But, if you like the pointer metaphore... you could use macro's
instead of procedures...
stupidly simple example...
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(define-macro (change-list lst) `(set! ,lst (map (lambda (i) (+ i 1)) ,lst))) (define mylist '(1 2 3 4 5)) (change-list mylist)