title: how to use erlang lists:map function
body: <p>The following is a erlang function. I don't understand how lists:map function is used here.
  Could someone please explain?</p>
  
  <pre><code>% perform M runs with N calls to F in each run.
  % For each of the M runs, determine the average time per call.
  % Return, the average and standard deviation of these M results.
  
  time_it(F, N, M) -&gt;
        G = fun() -&gt; F(), ok end,
        NN = lists:seq(1, N),
        MM = lists:seq(1, M),
        T = lists:map(
              fun(_) -&gt;
            T0 = now(),               % start timer
            [ G() || _ &lt;- NN ],           % make N calls to F
            1.0e-6*timer:now_diff(now(), T0)/N    % average time per call
          end,
          MM
            ),
        { avg(T), std(T) }.
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>also, I don't know the proper syntax when using this function. For example, I have a dummy() function take 1 parameter. I get an error while trying to time the dummy function.</p>
  
  <pre><code>moduleName:time_it(moduleName:dummy/1, 10, 100).
  </code></pre>
  
  <p>the above would evaluate to illegal expression.</p>
  
  <p>Actually, now with the correct syntax, the function can be invoked correctly with:</p>
  
  <pre><code>moduleName:time_it(fun moduleName:dummy/1, 10, 100).
  </code></pre>
  
  <p>However, it will throw a exception saying invoking dummy function without passing any parameter. I think this line is the villain, <code>[ G() || _ &lt;- NN ],</code> I have no idea how to fix it.</p>