Lecture overview -- Keyboard shortcut: 'u'  Previous page: List functions -- Keyboard shortcut: 'p'  Next page: Property lists -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Introduction to Functional Programming in Scheme - slide 16 : 49

Association lists

An association list is a list of cons pairs

Association lists are used in the same way as associative arrays

Expression

Value

(define computer-prefs 
 '((peter . windows) (lars . mac)
   (paw . linux) (kurt . unix)))
(assq 'lars computer-prefs)
(lars . mac)
(assq 'kurt computer-prefs)
(kurt . unix)
(define computer-prefs-1
 (cons (cons 'lene 'windows) 
       computer-prefs))
computer-prefs-1
((lene . windows)
 (peter . windows) 
 (lars . mac)
 (paw . linux)
 (kurt . unix))
Go to exercise
Creation of association lists
Go to exercise
Association lists and property lists