我想缩进下面这段代码。 一个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)))))
答案 0 :(得分:5)
(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)))))
我是怎么做的。
答案 1 :(得分:1)
除了@ dnolen的回答之外,我通常会在
时添加新行cond
块)然后只需对齐和缩进行,以便标识符合相同的代码深度。