fix for-each.
This commit is contained in:
parent
07a5f716fc
commit
8c1a5f19da
2
mes.c
2
mes.c
|
@ -342,8 +342,6 @@ eval (scm *e, scm *a)
|
|||
#if DEBUG
|
||||
printf ("\neval e=");
|
||||
display (e);
|
||||
printf ("\na=");
|
||||
display (a);
|
||||
puts ("");
|
||||
#endif
|
||||
scm *macro;
|
||||
|
|
6
scm.mes
6
scm.mes
|
@ -158,8 +158,10 @@
|
|||
|
||||
(define (identity x) x)
|
||||
(define (for-each f l . r)
|
||||
(apply map (cons f (cons l r)))
|
||||
*unspecified*)
|
||||
(cond ((null? l) '())
|
||||
((null? r) (f (car l)) (for-each f (cdr l)))
|
||||
((null? (cdr r))
|
||||
(for-each f (cdr l) (cdar r)))))
|
||||
|
||||
(define (not x)
|
||||
(cond (x #f)
|
||||
|
|
1
test.mes
1
test.mes
|
@ -95,6 +95,7 @@
|
|||
(pass-if "map" (sequal? (map identity '(1 2 3 4)) '(1 2 3 4)))
|
||||
(pass-if "map 2 " (sequal? (map (lambda (i a) (cons i a)) '(1 2 3 4) '(a b c d))
|
||||
'((1 . a) (2 . b) (3 . c) (4 . d))))
|
||||
(pass-if "for-each" (sequal? (let ((acc '())) (for-each (lambda (x) (set! acc (cons x acc))) '(1 2 3 4)) acc) '(4 3 2 1)))
|
||||
(define xxxa 0)
|
||||
(pass-if "set! " (seq? (begin (set! xxxa 1) xxxa) 1))
|
||||
(pass-if "set! 2" (seq? (let ((a 0)) (set! a 1) a) 1))
|
||||
|
|
Loading…
Reference in a new issue