ex6.10 - generalised functions for map, map2, flatMap and sequence