write function of higher order ateach f xs
applying default function f
each element of list xs
.
ateach succ [1 5] = [2,3,4,5,6] ateach length ["haskell", "go", "forward"] = [7,5,8]
as dave4420 pointed out, ateach
seems standard map
function (please clarify if not). if case, have different ways implement it, e.g.:
-- direct recursion ateach _ [] = [] ateach f (x:xs) = ??? -- list comprehension ateach f xs = [??? | x <- xs] --using fold ateach f = foldr ??? []
i don't want spoil fun, can try fill out ???
.
Comments
Post a Comment