There is code of fold function in Haskell programming.
map' ::(a->b)->[a]->[b]
map' f xs=foldr(\x acc ->f x:acc)[] xs
INPUT:
map' (+3) [1,2,3]
OUTPUT:
[4,5,6]
It takes the element from right side due to foldr function and I Want to take the element from left side and append into list and i want a output [6,5,4].i did it through foldl function but it gives error.
ERROR: Couldn't match expected type `a' with actual type `[b]'
`a' is a rigid type variable bound by
the type signature for map' :: (a -> b) -> [a] -> [b]
at doubleme.hs:1:8
In the first argument of `f', namely `x'
In the first argument of `(:)', namely `f x'
In the expression: f x : acc