exercise-23.scm (502B)
1 ;; Exercise 2.23 2 3 (define (exercise-2.23) 4 (define (my-for-each proc lst) 5 (cond 6 ((null? lst) 7 '()) 8 (else 9 (proc (car lst)) 10 (my-for-each proc 11 (cdr lst))))) 12 13 (define xs (list 1 2 3 4)) 14 15 (test-begin "2.23") 16 (test-equal 17 '(1 2 3 4 5 6) 18 (begin 19 (my-for-each (lambda (x) 20 (set! xs (append xs 21 (list x)))) 22 '(5 6)) 23 xs)) 24 (test-end "2.23")) 25 26 (exercise-2.23)