[erlang-questions] Where is the syntax error.

Hugo Mills hugo@REDACTED
Thu Sep 24 14:51:00 CEST 2015


On Thu, Sep 24, 2015 at 02:45:06PM +0200, Roelof Wobben wrote:
> 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.

   Well, like the error message says, it's something to do with a dot.

   You've got two dots in that line of code. Which one is wrong?
Hint: a dot is the end of an expression to be evaluated (in the shell)
or the end of a function definition (in a module).

   Hugo.

-- 
Hugo Mills             | 2 + 2 = 5, for sufficiently large values of 2.
hugo@REDACTED carfax.org.uk |
http://carfax.org.uk/  |
PGP: E2AB1DE4          |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150924/605359be/attachment.bin>


More information about the erlang-questions mailing list