add for-each

This commit is contained in:
Yuichi Nishiwaki 2013-11-15 22:57:46 +09:00
parent a68b470e06
commit d9749ef854
1 changed files with 17 additions and 0 deletions

View File

@ -155,6 +155,23 @@
(single-map f list) (single-map f list)
(multiple-map f (cons list lists)))) (multiple-map f (cons list lists))))
(define (for-each f list . lists)
(define (single-for-each f list)
(if (null? list)
#f
(begin
(f (car list))
(single-for-each f (cdr list)))))
(define (multiple-for-each f lists)
(if (any null? lists)
#f
(begin
(apply f (map car lists))
(multiple-for-each f (map cdr lists)))))
(if (null? lists)
(single-for-each f list)
(multiple-for-each f (cons list lists))))
(define-macro (let bindings . body) (define-macro (let bindings . body)
(if (symbol? bindings) (if (symbol? bindings)
(begin (begin