;Assuming listofLists is a list of lists, ;This function returns a list composed of the first ;element of each list. (define getFirstAtomOfEach (lambda (listofLists) (getFirstAtomOfEach_recurse listofLists ()) ) ) (define getFirstAtomOfEach_recurse (lambda (listofLists listofFirstAtoms) (cond ((null? listofLists) (reverse listofFirstAtoms) ) (else (getFirstAtomOfEach_recurse (cdr listofLists) (cons (car (car listofLists)) listofFirstAtoms ) ) ) ) ) ) ;============== Unit Tests ====================== (load "test.scm") (define msg "getFirstAtomOfEach") (test msg (getFirstAtomOfEach '((a aa) (b bb bbb) (c cc))) '(a b c) ) (test msg (getFirstAtomOfEach '((a aa))) '(a) )