title: Erlang function for()?
body: <p>From my understanding Erlang doesn't have the capabilities to do a for loop. However in this code snippet it uses the function for() in it. I don't really understand this for() function so any help is apprechiated.</p>
  
  <pre><code>-module(helloworld). 
  -export([max/1,start/0]). 
  
  max(N) -&gt; 
     Max = erlang:system_info(process_limit), 
     io:format("Maximum allowed processes:~p~n" ,[Max]), 
  
     statistics(runtime), 
     statistics(wall_clock), 
  
     L = for(1, N, fun() -&gt; spawn(fun() -&gt; wait() end) end), 
     {_, Time1} = statistics(runtime),
     {_, Time2} = statistics(wall_clock),
     lists:foreach(fun(Pid) -&gt; Pid ! die end, L),
  
     U1 = Time1 * 1000 / N, 
     U2 = Time2 * 1000 / N, 
     io:format("Process spawn time=~p (~p) microseconds~n" , [U1, U2]).
  
  wait() -&gt;
     receive 
        die -&gt; void 
     end. 
  
  for(N, N, F) -&gt; [F()]; 
  for(I, N, F) -&gt; [F()|for(I+1, N, F)]. 
  
  start()-&gt;
     max(1000), 
     max(100000).
  </code></pre>
  
  <p>Also what's the difference in run time and wall_clock in Erlang? I believe that wallclock is based off computers clock while runtime is based off of some sort of ticks in Erlang? I may be wrong though</p>