A basic question
Richard O'Keefe
raoknz@REDACTED
Mon Mar 2 12:37:47 CET 2020
Just as a matter of curiosity, and perhaps as a step towards
improving documentation, where did you get the idea that
myfunc(Val) ->
was valid Erlang?
Are you aware of the on-line reference manual at
https://erlang.org/doc/reference_manual/introduction.html
Section 8.18 describes 'fun's.
On Sun, 1 Mar 2020 at 22:28, salil GK <gksalil@REDACTED> wrote:
>
> Hello
> I just started learning Erlang. I fail to understand the error I am
> getting while compiling the below program.
>
> >>>>>
>
> -module(hw).
>
> %% API
> -export([ for/2, forloop/1]).
>
>
> for([],_) ->
> [];
> for([X|Xs], Func) ->
> Func(X),
> for(Xs, Func).
>
> forloop(X) ->
> Fn = myfunc(Val) ->
> io:fwrite("From myfunc ~w" , [Val]) end,
> for(X, Fn).
>
> <<<<<
>
> basically I am trying to make a for loop with a call back function.
> I am getting the following error while compiling
> hw.erl:23: syntax error before: '->'
> line 23 is
> Fn = myfunc(Val) ->
>
> ~S
More information about the erlang-questions
mailing list