A basic question

salil GK gksalil@REDACTED
Sun Mar 1 08:10:18 CET 2020


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