Implement the following functions using the previous 'reduce' with the right primitives for 'apply', 'accumulate' and 'base'.
forEach(E <:Ok i :Iter.T(E) statement(:E) :Ok) :Ok
(* Executes for all elements of i the function 'statement'. *)
map(E, F <:Ok i :Iter.T(E) f(:E) :F) :Iter.T(F)
(* Returns an iteration over the results of function 'f'
applied to each element of 'i'. *)
select(E <:Ok i :Iter.T(E) p(:E) :Bool) :Iter.T(E)
(* Returns an iteration over the elements of 'i'
that fulfill predicate 'p'. *)
maximum(E <:Ok i :Iter.T(E) greater(:E :E) :Bool) :E
(* Returns the "maximum" element of 'i' with respect to
comparisons by 'greater' *)
sum(E, V <:Ok i :Iter.T(E) getValue(:E) :V
zero :V addValues(:V :V) :V) :V
(* No comment! *)