One important characteristic of the map function is that it can be used reversibly. For example, (partial map inc) is inverted by (partial map dec). If I want to map over a collection by a function that takes the entire collection as an argument I'd rather use some function other then map to avoid confusion.
Hmm? What is the reverse of (partial map constantFunctionReturnsZero)?
A fold/reduce is just as sometimes-reversible, when paired with an appropriate unfold. (example: multiplication and factorization)
I think you mean that map is self-composable, in the sense that the map function distributes over function-composition, in the same way that (in first-order functions) multiplication distributes over addition.
The information lost by calling the constant function is pushed to the end of the list so that it can be called reversibly. This can be applied on an entire list:
Comments
One important characteristic of the map function is that it can be used reversibly. For example, (partial map inc) is inverted by (partial map dec). If I want to map over a collection by a function that takes the entire collection as an argument I'd rather use some function other then map to avoid confusion.
or just call a closure bound to the whole list. I think I would write the thing as a for loop though, it feels so un map like
Alternatively, you could partially apply the entire list to the function.
Hmm? What is the reverse of (partial map constantFunctionReturnsZero)?
A fold/reduce is just as sometimes-reversible, when paired with an appropriate unfold. (example: multiplication and factorization)
I think you mean that map is self-composable, in the sense that the map function distributes over function-composition, in the same way that (in first-order functions) multiplication distributes over addition.
> What is the reverse of (partial map constantFunctionReturnsZero)?
The function (constantly 0) is implemented as a place in order to maintain reversibility semantics:
The information lost by calling the constant function is pushed to the end of the list so that it can be called reversibly. This can be applied on an entire list: > A fold/reduce is just as sometimes-reversibleThe reduce function is not reversible, but the reductions function when called with a group is:
The reduce value is the last element of the list so it can be retrieved by the last place: > I think you mean that map is self-composableThe preservation of information is more important to me then composition.