在 netlogo 中乘以列表列表

Multiplying lists of lists in netlogo

我有两个不同的列表(list1list2),因此:

list1  = [ [a1 a2 a2] 
           [b1 b2 b3] ]

list2  = [ [c1 c2 c3] 
           [d1 d2 d3] ]

我想按以下方式将列表相乘,创建一个新的 list3 这样。

list3 = [ [a1\*c1  a2\*c2  a3\*c3] 
          [b1\*d1  b2\*d2  b3\*d3]]

我可以编写一个遍历每个元素的循环,但是,我认为可能有更好的方法以某种方式使用 netlogo 中的 map 函数。

感谢您的回答!

我不确定这是否非常优雅,但双映射将处理任意数量的列表列表。

to test
  let list1 [ [2 6 12] [20 30 42] ]
  let list2 [ [1 2 3] [4 5 6] ]
  let list3 (map [[x1 x2] -> (map [[y1 y2] -> y1 / y2] x1 x2) ] list1 list2)
  show list3
end