Skip to content

Commit f0b11fa

Browse files
committed
exercise 4.44: zip-with with reverse
1 parent 87cf6ae commit f0b11fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

chapter4/chapter4.03.scm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@
342342
(if (or (null? a) (null? b))
343343
acc
344344
(go (cdr a) (cdr b) (cons (op (car a) (car b)) acc))))
345-
(go a b '()))
345+
(define (reverse lst)
346+
(define (go lst acc)
347+
(if (null? lst)
348+
acc
349+
(go (cdr lst) (cons (car lst) acc))))
350+
(go lst '()))
351+
(reverse (go a b '())))
346352

347353
(zip-with list '(1 2 3) '(a b c d))

0 commit comments

Comments
 (0)