我在转换器的 1-arity 上产生多个元素,而序列只有考虑最后一个。
以下是转换器和序列测试失败的示例
`
(defn 滑动窗口 [n]
(fn [rf]
(let [a #js []]
(fn
([] (rf))
([result]
(loop [] ;; Here I'm emitting more than one element
(when (not-empty a)
(rf result (vec (js->clj a)))
(.shift a)
(recur))))
([result input]
(.push a input)
(if (== n (.-length a))
(let [v (vec (js->clj a))]
(.shift a)
(rf result v))
result))))))
;; 此测试失败! =(
(deftest 滑动窗口序列测试
(is (= [[5 4 3]
[4 3 2]
[3 2 1]
[2 1]
[1]]
(sequence (sliding-window 3) [5 4 3 2 1])))
(is (= [[2 1]
[1]]
(sequence (sliding-window 3) [2 1]))))
`