Arc Forumnew | comments | leaders | submitlogin
8 points by absz 6149 days ago | link | parent

It looks like your confusion is about what zap does. zap is not a destructive variant of map; zap has no relation to map at all. What zap is is a generalized version of =. You often see expressions of the form (= foo (bar foo)), and zap abstracts them and add redundancy. When you write (zap func name), Arc will expand that into (= name (func name)). So in your first example, (zap [+ _ 10] x) turned into (= x ([+ _ 10] x)), which is the same as (= x (+ x 10)); x is the list '(1 2 3), and you can't add a number to a list, so you get an error. Cchooper's example, on the other hand, turns into (= x ([map [+ _ 10] _] x)), which is the same as (= x (map [+ _ 10] x)), which, as you can see, does what you want.


3 points by NickSmith 6149 days ago | link

Ahhh... now I see! It irked me a little that I knew the answer but didn't fully understand the reasoning. Thank you absz, this is really helpful.

-----

2 points by absz 6149 days ago | link

Glad to be of assistance :)

-----