I am trying to solve this exercise. It is about reimplementing the map
function in haskell for learning purpose. I found a solution which doesn't browse all the elements of the list (simple linked list, so accessing the last element will browse all the list) at each iteration, but I didn't found one which is tail recursive.
accumulateRec :: (a -> b) -> [a] -> [b]
accumulateRec func [] = []
accumulateRec func (h:t) = (func h) : accumulateRec func t
Is there a way to implement map in a tail recursive way and without browsing all the list at each iteration ?
PS: exercism.io is an awesome way to learn a new language.