10-09-2013

posted Oct 9, 2013, 5:33 AM by Samuel Konstantinovich   [ updated Oct 9, 2013, 6:29 AM ]
Goal: More lists + Listception

Element: one thing inside of a list, it can be an atom or another list.
Atom: a single element that is not a list, such as: integers, floating points, strings.

Box diagrams of lists:
Every list has two components the car and the cdr, if you draw a list as a series of split boxes you can represent the list graphically. (see notes from board)

Draw a box diagram for the lists below:
'(1 9 3 2)
'(7 5 4 6)

Lists can contain other lists
Examples:
e1.  '( a b ( c d ) e f)  is a list with 5 top level elements, 4 of them are atoms, 1 is a list.
e2.  '( 1 (2 3) (4 5) ) is a list with 3 top level elements, 1 of them is an atom, 2 are lists.
e3.  '( (a b (c d) e f) ) is a list with 1 top level element that is a list. This list contains the list from example 1.

These can also have box diagrams! (See notes from board)
'(a b (c d) e)

Draw a box diagram for the following lists:
L. '(a (b) (c d) e)
M.  '(a (b c) (d e) )
N.  '(a (b (c d) e) f)

Now write a scheme expression with car/cdr that you use on List N to: 1. extract the e.
2. extract the d.
Comments