4 ms·
> What is the reverse of (partial map constantFunctionReturnsZero)? The function (constantly 0) is implemented as a place in order to maintain reversibility s
by jhuni 14y ago
> What is the reverse of (partial map constantFunctionReturnsZero)?
The function (constantly 0) is implemented as a place in order to maintain reversibility semantics:
((constantly 0) 10) ;-> (0 10)
((constantly 0) 50) ;-> (0 50)
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:
(map (constantly 0) [1 2 3]) ;-> ([0 0 0] [1 2 3])
> A fold/reduce is just as sometimes-reversible
The reduce function is not reversible, but the reductions function when called with a group is:
(reductions + [1 2 3 4]) ;-> [1 3 6 10]
The reduce value is the last element of the list so it can be retrieved by the last place:
(last [1 3 6 10]) ;-> (10 [1 3 6])
> I think you mean that map is self-composable
The preservation of information is more important to me then composition.