why “and” can not be operation within accumulate in Racket-lang?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #lang racket (define (accumulate op initial sequence) (if (null? sequence) initial (op (car sequence) (accumulate op initial (cdr sequence))))) (define (all-is-true? items) (accumulate and true items)) (all-is-true? (list true true true)) |
输出为:
1 | and: bad syntax in: and |
我找不到为什么"和"过程不能成为累加操作的原因。
1 2 3 4 | (define (all-is-true? items) (accumulate (lambda (a b) (and a b)) true items)) |
不能将宏作为参数传递。它们只能作为应用程序的汽车出现。