[erlang-questions] Where is the syntax error.
Roelof Wobben
r.wobben@REDACTED
Thu Sep 24 18:05:13 CEST 2015
Op 24-9-2015 om 17:01 schreef Garry Hodgson:
> On 09/24/2015 08:54 AM, zxq9 wrote:
>> Debugging all day makes me bad at find-it-yourself hints... -Craig _
>
> I like to split my time between putting bugs in and taking them out.
>
Thanks,
One thing I do not see.
If I want to run this with a function with a argument.
-module(time).
-export([elapsed_time/1]).
elapsed_time(F) ->
Begintime = erlang:monotonic_time(),
F(),
Endtime = erlang:monotonic_time(),
Time = erlang:convert_time_unit(Endtime - Begintime,native ,
micro_seconds),
io:format("This took ~w microseconds", [Time]).
This is the wrong way to do this :
time:elapsed_time((Answer = fun(x) -> x + 2 end )2).
Can I solve this by chancing the function to this elapsed_time(F, arg)
and then do F(arg) ?
Roelof
time:elapsed_time((Answer = fun(x) -> x + 2 end )2).
time:elapsed_time((Answer = fun(x) -> x + 2 end )2).
More information about the erlang-questions
mailing list