我编写了一个Clojure函数,它使用recur处理列表并将结果返回到向量中...
(defn do_stuff [input, results]
;; using recur and conj here to build up results
)
我有另一个函数需要传递do_stuff的结果,我收到此错误:
没有实现方法:: to_my_format of protocol:#'com.beebunny.to_my_format for class:clojure.lang.ArraySeq
我的to_my_format函数有一个clojure.lang.IPersistentVector和IPersistentList的实现。有没有办法可以转换成其中一种?
感谢。
答案 0 :(得分:1)
一个简单的解决方法是用ArraySeq
包裹into
。
(into [] array-seq)
但如果您重构协议以使用ISeq
,如果您只需按顺序扫描数据并生成结果,则可能会更好。因此,任何顺序的内容都可以通过简单的seq
调用传入。