[英]How to use clojure.zip in 4clojure
I used followed codes to solve tree re-parenting the question in 4clojure, but the answer is the clojure.zip namespace is not required, under not modified my codes, how can I pass it? 我使用了跟随代码来解决4clojure中的树重新托管问题,但答案是不需要clojure.zip命名空间,在未修改我的代码的情况下,我该如何传递它?
(fn gen-tree
[nr tree]
(let [zp (clojure.zip/seq-zip tree)
pnodes (:pnodes (second
(first
(filter
(fn [[nd :as loc]]
(= nr nd))
(iterate clojure.zip/next zp)))))]
(reduce (fn [rs e]
(concat e (list (remove #(= e %) rs))))
pnodes)))
You can't. 你不能。 User code on 4clojure is not allowed to load namespaces. 4clojure上的用户代码不允许加载名称空间。
Aside: your code will fail for sufficiently large inputs, because of the reduce/concat problem shown in, for example, Why does reduce give a StackOverflowError in Clojure? 另外:您的代码将因为足够大的输入而失败,因为例如, 为什么reduce会在Clojure中给出StackOverflowError? . 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.