title: Erlang: Can this be done without lists:reverse?
body: <p>I am a beginner learning Erlang. After reading about list comprehensions and recursion in Erlang, I wanted to try to implement my own <code>map</code> function, which turned out like this:</p>
  
  <pre><code>% Map: Map all elements in a list by a function
  map(List,Fun) -&gt; map(List,Fun,[]).
  map([],_,Acc) -&gt; lists:reverse(Acc);
  map([H|T],Fun,Acc) -&gt; map(T,Fun,[Fun(H)|Acc]).
  </code></pre>
  
  <p>My question is: It feels wrong to build up a list through the recursive function, and then reverse it at the end. Is there any way to build up the list in the right order, so we don't need the reverse ? </p>