Example usages of the function make-selector-function. | Lecture 4 - slide 5 : 34 Program 2 |
1> (define first (make-selector-function 1 "first")) 2> (first '(a b c)) a 3> (first '()) The selector function first: The list () is is too short for selection. It must have at least 1 elements. > 4> (define (make-person-record firstname lastname department) (list 'person-record firstname lastname department)) 5> (define person-record (make-person-record "Kurt" "Normark" "Computer Science")) 6> (define first-name-of (make-selector-function 2 "first-name-of")) 7> (define last-name-of (make-selector-function 3 "last-name-of")) 8> (last-name-of person-record) "Normark" 9> (first-name-of person-record) "Kurt"