[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] General newbie query about tspl execise
From: |
Enwin Thun |
Subject: |
[Chicken-users] General newbie query about tspl execise |
Date: |
Thu, 4 Nov 2010 22:39:19 +0530 |
Please redirect me if this is inappropriate for this forum.
The following code appears in the tspl book.
<http://www.scheme.com/tspl3/start.html#./start:s185>
It is an "implementation of a queue use[ing] a tconc structure".
To put new elements into the end of the list, it is required that the
2 'ignored atoms are really the same.
This makes me curious about how atoms and lists are stored. I am
looking for a link that explains this in terms of memory addresses,
pointers, etc. A link for general discussion about memory management
in scheme would also be nice.
Thanks.
(define make-queue
(lambda ()
(let ((end (cons 'ignored '())))
(cons end end))))
(define putq!
(lambda (q v)
(let ((end (cons 'ignored '())))
(set-car! (cdr q) v)
(set-cdr! (cdr q) end)
(set-cdr! q end))))
(define getq
(lambda (q)
(car (car q))))
(define delq!
(lambda (q)
(set-car! q (cdr (car q)))))
- [Chicken-users] General newbie query about tspl execise,
Enwin Thun <=