我在编写可以遍历异构节点树的拉链时遇到问题。我有 i) 地图列表。每个地图都有 ii) 一个 :inputs 键,其值是地图列表。
我想使用拉链来访问每一片叶子并添加一个计算值。代码块和输入树数据如下。我似乎无法获取访问叶节点的拉链代码,并添加 { :thing 123 }。我一定错过了一些简单的东西。有什么见解吗?
一种)
(loop [loc (zip/zipper (or map?list?) #((if (map?%1) ;; 获取节点的子节点 (:输入 %1) %1)) #(%1) ;; 创建一个新节点 (:输入层神经网络))] (如果 (zip/end?loc) (zip/根目录) (如果(地图?位置) (重复(邮编/下一个 (zip/edit loc 合并 { :thing 123 } ))) (重复(zip/next loc)) ) ) )
二)
({:输入 ({:key :avolume, :value 2.25, :weight 0.4283380545172636, :bias 0} {:key :bvolume, :value 3.0, :weight 0.6970037374879661, :bias 0} {:key:ask,:value 1.32379,:weight 0.5387437158323669,:bias 0} {:key :bid, :value 1.3239, :weight 0.4648184032361037, :bias 0} {:key:time,:value 1.335902400676,:weight 0.43632873607404554,:bias 0}), :id "583c10bfdbd326ba34aed329139df6be2487ffc"} {:输入 ({:key :avolume, :value 2.25, :weight 0.13162215440222336, :bias 0} {:key :bvolume,:value 3.0,:weight 0.23886901184352727,:bias 0} {:key:ask,:value 1.32379,:weight 0.8408470512339872,:bias 0} {:key:bid,:value 1.3239,:weight 0.27071013797961796,:bias 0} {:key:time,:value 1.335902400676,:weight 0.6304505838898373,:bias 0}), :id "583c10bfdbd326ba34aed329139df6be2487ffd"} {:输入 ({:key :avolume, :value 2.25, :weight 0.8236972641966921, :bias 0} {:key :bvolume,:value 3.0,:weight 0.32421537754016705,:bias 0} {:key :ask, :value 1.32379, :weight 0.966306328543246, :bias 0} {:key :bid, :value 1.3239, :weight 0.8891668220470931, :bias 0} {:key:time,:value 1.335902400676,:weight 0.278993745549462,:bias 0}), :id "583c10bfdbd326ba34aed329139df6be2487ffe"} {:输入 ({:key :avolume, :value 2.25, :weight 0.27388486254027167, :bias 0} {:key :bvolume,:value 3.0,:weight 0.33659579299487363,:bias 0} {:key:ask,:value 1.32379,:weight 0.16610378593177033,:bias 0} {:key :bid, :value 1.3239, :weight 0.6964784902474896, :bias 0} {:key:time,:value 1.335902400676,:weight 0.6306732906337643,:bias 0}), :id "583c10bfdbd326ba34aed329139df6be2487fff"} {:输入 ({:key:avolume,:value 2.25,:weight 0.8819171698935051,:bias 0} {:key :bvolume,:value 3.0,:weight 0.5944805362120958,:bias 0} {:key:ask,:value 1.32379,:weight 0.9060962647355373,:bias 0} {:key:bid,:value 1.3239,:weight 0.37647418075176464,:bias 0} {:key:time,:value 1.335902400676,:weight 0.7797681719480866,:bias 0}), :id "583c10bfdbd326ba34aed329139df6be2488000"})
谢谢