Feedback Lists subsetneq Trees 

Forum: Com Sci 221, U Chicago, Autumn 2001, Old Classwork
Re: News Assignment #7 due Monday, 19 November (Mike O'Donnell)
Re: Question dynamic scope? and tree representation? (Terry (Sotiria) Lampoudi)
Date: 2001, Nov 19
From: Mike O'Donnell <odonnell@cs.uchicago.edu>

In LISP, every list is a tree, but not every tree is a list. The LISP jargon for tree is S-expression. A tree whose rightmost path from the root leads to nil is a list. A tree whose rightmost path from the root leads to an atomic symbol other than nil is not a list. Notice that a nonlist may have subtrees that are lists, and a list may have entries that are nonlists. A tree all of whose right edges lead either to internal nodes or nils is composed entirely of nested lists.

LISP has a slightly redundant notation, capable of describing all trees, but tuned to describe lists more concisely than other trees. The McCarthy article that I handed out covers this fairly thoroughly. For example, (a b c), (a b c . nil), (a b . (c . nil)), (a . (b . (c . nil))) all describe the same tree, which is a list. (a b c . d), (a b . (c . d)), (a . (b . (c . d))) all describe the same tree, which is not a list.




Mike O'D.


Messages

to: "Lists subsetneq Trees"