Note to self: do not re-implement fold and map with obscure functions in every program without noticing
refactoring