CS135 Lecture : Lists lists, sequences, and constructing lists. design recipe, data definitions, and template for lists, as well as dictionaries and association lists (critical for rest of course)

91 views3 pages

Document Summary

Eggs twice: this resembles a set in mathematics. Ex) the list representing the sequence 2,1 is: (cons 2 (cons 1 empty)). ;; a list is one of: empty (cons any list) Like a linked list in java, recursive definition of a value followed by the list it is preceding (like a node) The selectors that work on a list are first and rest: Substitution rules: (first (cons a b)))a gives you the first value (value) (rest (cons a b)))b gives you the second value (list) There are no restrictions on the first argument. [(cons? symblist) : the second test can be replaced by else, because cons is a special type of structure, we can add the selectors as in the structure template. [else . (first symblist) . (rest symblist) : since (rest symblist) is a list of symbols (because first condition, empty? failed, this must be true), we apply the same computation on it-that is we apply my-los-fn.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions