MC logo

Lisp Reference Counting Question


CS 404: Solutions and Examples

Consider the diagram below showing a Lisp symbol table and heap. Show the reference count for each node, then perform each of the following operations, updating the heap. Change the links as required, update the reference counts, deleting any unused nodes.
  1. (setq condfish (cdr codfish))

  2. (setq spam (cdr spam))

  3. (setq jones (cdr spam))

  4. (setq smith (cdr jones))

  5. (setq alice (cons spam drywall))     ; Spam and drywall construction.
What list does alice represent in the final heap?

>>