; Association lists ; built-in data structure which consists of a list of pairs ; the idea is that the first item in each pair is "associated" with the second ; for example: (define science-professors-directory (list (cons "Bruce Voyles" "3038") (cons "Diane Robertson" "3039") (cons "Martin Minelli" "3007") (cons "Arnold Adelberg" "4201") (cons "Mark Schneider" "3018") (cons "Janet Gibson" "3168"))) ; you can call assoc in the following way: ; (assoc KEY ASSOCIATION-LIST) ; and then Scheme will return the pair in ASSOCIATION-LIST whose first ; element is KEY, and returns #f if none exists (define my-assoc (lambda (key alist) (if (null? alist) #f ; note that (caar alist) is short for (car (car alist)) (if (equal? (caar alist) key) (car alist) (my-assoc key (cdr alist))))))