gpt4 book ai didi

clojure - 如何正确缩进 clojure/lisp?

转载 作者:太空宇宙 更新时间:2023-11-03 18:35:37 24 4
gpt4 key购买 nike

我想缩进以下代码。lisper 会如何缩进这个?我对在哪里放置换行符感到特别困惑。

(defn primes [n]
(letfn [(sieve [table removal]
(assoc table removal false))
(primebools [i table]
(cond
(= i n) table
(table i) (recur (inc i)
(reduce sieve
table
(range (* i i) n i)))
:else (recur (inc i)
table)))]
(let [prime? (primebools 2 (apply vector (repeat n true)))]
(filter prime? (range 2 n)))))

最佳答案

(defn primes [n]
(letfn [(sieve [table removal]
(assoc table removal false))
(primebools [i table]
(cond
(= i n) table
(table i) (recur (inc i)
(reduce sieve table
(range (* i i) n i)))
:else (recur (inc i) table)))]
(let [prime? (primebools 2 (apply vector (repeat n true)))]
(filter prime? (range 2 n)))))

我会怎么做。

关于clojure - 如何正确缩进 clojure/lisp?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6335886/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com