评论由 reborg 提出
垃圾输入/垃圾输出的情况,但rem也有责任
用户=> (take-nth 2.5 (range 10))
(0 3 6 9)
用户=> (sequence (take-nth 2.5) (range 10))
(0 5)
Steve(CLJ-1665-faster-take-nth-transducer-without-rem.patch)提出的补丁只是缺少将上述内容转换为int的转换来解决问题
(defn take-nth [n]
(fn [rf]
(let [n (int n)
iv (volatile! 1)]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [i (vswap! iv dec)]
(if (zero? i)
(do (vreset! iv n)
(rf result input))
result)))))))