paip-lisp icon indicating copy to clipboard operation
paip-lisp copied to clipboard

Errata for queues in chapter 10

Open darius opened this issue 3 years ago • 0 comments

Back in the 1990s I remember finding a bug in the queues code. Since I've lost the email and forgotten the problem, I'll try to reconstruct it now.

The code in chapter10.md appears to be unchanged from pp. 342-343 of the scanned pdf of the book.

queue-nconc looks wrong on the case when q is empty and list is null: after running (queue-nconc (make-queue) nil), the queue structure will be (nil . nil), which is not a valid queue representation (the car should point back to the queue structure itself).

I think the other 3 cases for queue-nconc are OK (q is nonempty or list is nonnull), but I haven't checked carefully.

The other functions look right -- I sketched box-and-pointer graphs before and after for the cases where q is empty or nonempty.

darius avatar Mar 20 '22 01:03 darius