我正在使用 specter 在 Clojure 中转换嵌套数据结构,但我还没有掌握它。特别是,我正试图创建一个转换,它将找到与谓词匹配的任何深度的项,并用多个项替换它。
[:top
[:arbitrary 1 2
[:nesting
2
3
[:needle] ; <-- the thing to find
]]]
-->
[:top
[:arbitrary 1 2
[:nesting
2
3
[:n1] [:n2] [:n3] ; <-- 3 items inserted in the place of 1
]]]
我无法弄清楚的是如何将替换项目拼接到父向量中,即如何用三个项目替换一个项目,而不是用包含三个子项的单个项目替换一个项目。