Error in Netlogo foreach when trying to find the diff between two list items

Viewed 169

I am trying to take the difference per position of two arrays and put them in a third array:

let list1 [ 3 4 5 ]
let list2 [ 6 7 8 ]
let list3 [ ]

( foreach list1 list2 [
  [ a b ] -> lput ( a - b ) list3
] )

Ideally, I would have list3 be [ -3 -3 -3 ] after.

When I try to run it, I get this error:

FOREACH expected this input to be an anonymous command, but got an anonymous reporter instead

What am I doing wrong? I have tried putting parenthesis around the function, but I'm very new to NetLogo.

Note: I'm using NetLogo 6.0.1.

1 Answers
Related