title: ERLANG, map for infinite list
body: <p>I wanted to write a map for an infinite list.
  This is, what I have so far:</p>
  
  <pre><code>-module(map).
  -export([ints/0,take/2,map/2, double_int/1]).
  
  ints() -&gt; ints_from(0).
  
  take(0, _)         -&gt; [];
  take(N, [H|LazyT]) -&gt; [H | take(N-1, LazyT())].
  
  double_int(N) -&gt; 2 * N.
  
  map(_, []) -&gt; [];
  map(F, [H | T]) -&gt; [F(H) | map(F, T())].
  
  ints_from(N) -&gt; [N | fun () -&gt; ints_from(N+1) end].
  </code></pre>
  
  <p>The problem is, that with the call</p>
  
  <pre><code>&gt; L = map:ints().
  [0|#Fun&lt;map.0.104601022&gt;]
  &gt; R = map:map(fun map:double_int/1, L).
  </code></pre>
  
  <p>I get a never ending process. I guess, the map is proceeding through the whole infinite list and therefore never ending.</p>
  
  <p>What am I doing wrong?</p>