[erlang-questions] Where is the syntax error.

Roelof Wobben <>
Thu Sep 24 14:45:06 CEST 2015


Hello,

For a exercise I had to write a function which keeps track how long a 
anymous function takes with the help of time:now.

So I have this :

-module(time).

-export([elapsed_time/1]).

elapsed_time(F) ->
     Begintime = erlang:monotic_time(),
     F(),
     Endtime = erlang:monotonic_time(),
     Time = erlang:convert_timeunit(Endtime - Begintime,native , 
micro_seconds),
     Time.


Now I want to test it in erl.
But then I see this output:

time:elapsed_time(Answer = fun() -> io:format("Sucess") end. ).
  * 1: syntax error before: '.'

Can someone give me  a tip where the syntax errror is.

Roelof



More information about the erlang-questions mailing list