University of California, Berkeley
EECS Department - Computer Science Division

CS3 OaW Lecture 12 : Advanced Lists


Association Lists

: (define my-a-list '((dan garcia) (george bush) (bill clinton) (bill cosby)))
: (assoc 'dan my-a-list)
(dan garcia)
: (assoc 'bill my-a-list)
(bill clinton)
: (assoc 'raoul my-a-list)

Functions with an arbitray number of arguments

;; greetings
;; INPUTS       : A first name, last name and (optional) letters

;; RETURNS      : A greeting for the person

(define (greetings first-name last-name . letters)
   (append (list 'hello first-name last-name) letters))
: (greetings 'madonna)
*** Error:
    too few arguments to: (greetings (quote madonna))
Current eval stack:
  0    (greetings (quote madonna))
: (greetings 'barack 'obama)
(hello barack obama)
: (greetings 'maick 'griebenow 'md 'dds 'phd 'frcmfs)
(hello maick griebenow md dds phd frcmfs)

Recursion on Arbitrary Structured Lists (car/cdr recursion)


In Lab this week you'll see...

In Life this week you'll see...