Today in 151: Symbols and Lists Overview: * What is a symbol? * What is a list? * Lab * Reflection Administrivia: * Eschew obfuscation * Any thoughts on the Eboards? * Do you mind visitors from other classes? (Other 151, 153, 195) * Homework 1 due + The HTML validator was down this morning. I'll accept invalid HTML (but I'll still probably critique it). * Read "Numbers in Scheme" * Finish this lab on your own ---------------------------------------- Thought involves symbolic manipulation in collections of symbols * Have I seen this concept before? * We need "symbolic values" in the language A symbol is + Atomic + Useful for comparison * In scheme 'cat (define cat "Katherine") Collections of things: * List * An ordered group of things * In Scheme, ordered group of things of different types + Not legal in many other languages * Ways to build lists in Scheme > (list 'a 'b 'c) (a b c) > '(a b c) (a b c) DON'T USE THE SINGLE QUOTE > (list 'cat cat) (cat "Katherine") Create the empty list with null or () > null () Add something to front of a list with cons > (cons 'a null) (a) > (cons 'a (cons 'b null)) (a b) Can you define something as a list. Certainly > (define foo (cons 'a null)) > (cons 'b foo) (b a) (car lst) -> First element of list (cdr lst) -> All but the first element of list ---------------------------------------- REFLECTION * If there's a dot in your list, something's wrong * What is (list list)? * Escape-P gives you "the previous thing" and lets you edit it. (Escape is in the upper-left-hand corner) * Yes, it's good to talk to each other "Why is the length of (a (b c) (d (e))) equal to 3?" "Well, that says there are three elements, let's look at how we built it ..." * You build lists from right to left