CS135 Lecture 5: Module 005
117 views2 pages
9 Nov 2015
School
Department
Course
Professor
Document Summary
: consumes a value and produces true if it is a cons value and false otherwise. Semantics of list functions: (cons a b) is a value. There are no restrictions on the values of the first argument, allowing us to mix data types in a list (and even have lists of lists: b must be a list (empty is a list) List data definition: ;; a list-of-symbols is one of, ;; * empty, ;; * (cons sym list-of-symbols) Informally: a list of symbols is either empty, or it consists of a first symbol followed by a list of symbols (the rest of the list). This is a recursive definition, with a base case, and a recursive (self-referential) case. A function is recursive when the body of the function involves an application of the same function. Condensed traces not needed to know or understand. Structural recursion the form of the code matches the form of the data definition.