1

I have three lists [a1 a2 a3 a4][b1 b2 b3 b4][c1 c2 c3 c4]

I want to create a new list by adding elements of each list

Result: [a1+b1+c1 a2+b2+c2 a3+b3+c3 a4+b4+c4]

1 Answers1

2

Checkout map:

(map [ [a b c] -> a + b + c ] list1 list2 list3)

Bryan Head
  • 12,360
  • 5
  • 32
  • 50
  • 3
    @JuanDavidArredondo Bryan's code produces a list. You have to tell NetLogo what you want to do with that list (e.g., print it). – Alan May 09 '18 at 20:00
  • 3
    This is a very good candidate for using the [concise syntax](https://ccl.northwestern.edu/netlogo/docs/programming.html#concise-syntax) of anonymous procedures: `(map + list1 list2 list3)`. – Nicolas Payette May 09 '18 at 20:41