当然可以,
(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]
(cond (= sequence nil) nil
(predicate (first sequence))
(cons (first sequence) (lazy-seq (filter-lazy-seq predicate
(rest sequence))))
:else (filter-lazy-seq predicate (rest sequence))))
(defn 自然数生成器 []
(letfn [(辅助函数 [n]
(cons n (lazy-seq (辅助函数2 (inc n)))))]
(辅助函数 1))
)
(def 自然数 (自然数生成器))