当然可以,
(defn is_prime [num]
(letfn [(helper [i]
(cond
(> i (Math/sqrt num)) true
(<== 0 (rem num i)) false
:else (recur (inc i))))]
(helper 2)))
;返回一个延迟序列,序列中的每个下一个元素都通过谓词筛选
(defn filter-lazy-seq [predicate sequence]
(当 seq = nil 时) nil
(pred (first seq))
(cons (first seq) (lazy-seq (filter-lazy-seq pred
(rest seq)))))
:else (filter-lazy-seq pred (rest seq))))
(defn 自然数的生成 []
(letfn [(辅助 [n]
(cons n (lazy-seq (辅助2 (inc n)))))]
(辅助 1))
)
(def 自然数 (自然数的生成))