;;;; Section 1.6 ;;;; ;Adam Nelson ;Chet Tobrey (defparameter *titles* '(mr mrs miss ms sir madam dr admiral major general) "A list of titles that can appear at the start of a name.") (defun first-name2 (name) "Selects the first name from a name represented as a list." (if (member (first name) *titles*) (first-name (rest name)) (first name))) (egs :1.6 (eg '(mapcar #'last-name names) :of "Calls last-name function on every element of the input list by using mapcar" :out '(public x hopper spot aristotle milne top olivier scarlet)) (eg '(mapcar #'- '(1 2 3 4)) :of "Uses the mapcar function on a list of numbers" :out '(-1 -2 -3 -4)) (eg '(mapcar #'+ '(1 2 3 4) '(10 20 30 40)) :of "Uses the mapcar function on two lists of numbers" :out '(11 22 33 44)) (eg '(mapcar #'first-name names) :of "Uses the mapcar function on the first-name function with the names list" :out '(john malcolm admiral spot aristotle a z sir miss)) (eg '(mapcar #'first-name2 names) :of "Uses mapcar on the next first-name function" :out '(john malcolm grace spot aristotle a z larry scarlet)) (eg '(first-name2 '(madam major general paula jones)) :of "Tests the new first name function with titles and a name" :out 'Paula) (eg '(trace first-name2) :of "Turns on trace for the first-name2 function" :out '(first-name2)) (eg '(first-name2 '(john q public)) :of "Uses the trace on the first name function" :out 'John) (eg '(first-name2 '(madam major general paula jones)) :of "Uses the trace on the first name function with certain titles and a name" :out 'Paula) (eg '(untrace first-name2) :of "Untraces the function" :out '(first-name2)) (eg '(first-name2 '(mr blue jeans)) :of "Tests the first name function with a title and a name" :out 'Blue))