map accepts a function and a list and applies this function to each element of the list. eg.
(map f [x1 x2 x3]) ;= [(f x1) (f x2) (f x3)]
Mathematically, a list is a partial function of natural numbers β. If x: β β X is a list and f: X β Y is a function, then the map takes the pair (f, x) to the list f β x: β β Y. Therefore, map and comp return the same value at least in the simple case.
However, when we use a map with more than one argument, something more complex happens. Consider an example:
(map f [x1 x2 x3] [y1 y2 y3]) ;= [(f x1 y1) (f x2 y2) (f x3 y3)]
Here we have two lists x: β β X and y: β β Y with the same domain and a function of type f: X β (Y β Z). To evaluate on a tuple (f, x, y), the map needs to do some more work behind the scenes.
First, the map builds a diagonal list of products diag (x, y): β β X Γ Y, which is determined by diag (x, y) (n) = (x (n), y (n)).
Secondly, the map expands the function curry -1 (f): X Γ Y β Z. Finally, the map compiles these operations to get curry -1 (f) β diag (x, y): β β Z.
My question is: does this template generalize? Namely, suppose we have three lists x: β β X, y: β β Y and z: β β Z and a function f: X β (Y β (Z β W))). Does the map map the tuple (f, x, y, z) to the curry list -2 (f) β diag (x, y, z): β β W?