>>10The simplest example would be
modifiedCollection = fmap f collection
. Here there are no indices, and
collection
could be anything from a linked list to array to tree to hash-table, with any type of element as long as function
f
has one argument of the same type as the collection's elements. The result is a new collection of same type (but possibly different type of elements - the same as
f
's return type) and same number of elements.
I don't even know how to do that in C without using type-unsafe
(void *)
function pointers. You probably would need some
_generic
keywords to branch on the collection type.