我正在尝试编写一个过程来定义所有不能被2,3或5分割的整数流。这就是我写的:
(define not-d
(stream-filter (lambda (x) (not (divisible? x (and 2 3 5))))
integers))
我测试它:
(define (take n s) ;; list of first n things from stream s
(if (= n 0)
'()
(cons (stream-car s) (take (- n 1) (stream-cdr s)))))
然而它不起作用......我该如何解决这个问题?
答案 0 :(得分:3)
这根本不起作用:
(not (divisible? x (and 2 3 5)))
请改为尝试:
(and
(not (divisible? x 2))
(not (divisible? x 3))
(not (divisible? x 5)))