This is the mail archive of the guile@cygnus.com mailing list for the guile project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
The problem:
~~~~~~~~~~~
guile> (use-modules (ice-9 q))
guile> (define q (make-q))
guile> q
(())
guile> (enq! q 'a)
(a)
guile> q
((a) a)
guile> (deq! q)
a
guile> q
(() a)
guile> (q-empty? q)
#t
guile> (enq! q 'b)
(b)
guile> q
(() b)
guile> (q-empty? q)
#t
That is, once q became empty, it's impossible to add stuff at the end.
The fix:
~~~~~~~
*** /usr/local/share/guile/1.3a/ice-9/q.scm Fri Apr 24 21:54:50 1998
--- q.scm Wed Apr 29 18:01:26 1998
***************
*** 111,117 ****
(define-public (enq! q d)
(let ((h (cons d '())))
(if (not (null? (cdr q)))
! (set-cdr! (cdr q) h)
(set-car! q h))
(set-cdr! q h)))
--- 111,118 ----
(define-public (enq! q d)
(let ((h (cons d '())))
(if (not (null? (cdr q)))
! (set-cdr! (cdr q) h))
! (if (null? (car q))
(set-car! q h))
(set-cdr! q h)))