Skip to content

Commit

Permalink
Finished chapter 19 exercises (skipping one)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Buntine committed Jan 23, 2010
1 parent 837ae18 commit bb843ce
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 19-implementing-higher-order-functions/19-13.scm
@@ -0,0 +1,12 @@
; Write deep-reduce, similar to tree-reduce, but for structured lists:
;
; > (deep-reduce word ’(r ((a (m b) (l)) (e (r)))))
; RAMBLER

(define (deep-reduce func lst)
(cond ((null? lst) (func))
((list? (car lst))
(func (deep-reduce func (car lst))
(deep-reduce func (cdr lst))))
(else (func (car lst)
(deep-reduce func (cdr lst))))))

0 comments on commit bb843ce

Please sign in to comment.