45 seconds | Name binding, Recursion, Iteration, and Continuations - slide 17 : 42 |
A list is a recursive data structure
As a consequence list processing is done via recursive functions
We illustrate list processing by extracting attribute values from a LAML attribute property list
; Return the href attribute value from a property list ; Return #f if no href attribute is found. ; Pre-condition: attr-p-list is a property list - ; of even length. (define (find-href-attribute attr-p-list) (if (null? attr-p-list) #f (let ((attr-name (car attr-p-list)) (attr-value (cadr attr-p-list)) (attr-rest (cddr attr-p-list))) (if (eq? attr-name 'href) attr-value (find-href-attribute attr-rest)))))