Answer by dsmith for Erlang getting error ** 1: syntax error before: '->' **
Or use the lists:foldl/2 function. This is copied directly from the Erlang Reference Manual. 1> lists:foldl(fun(X, Sum) -> X + Sum end, 0, [1,2,3,4,5]). 15
View ArticleAnswer by rvirding for Erlang getting error ** 1: syntax error before: '->' **
The straight answer is that in a module definition file you have attributes, like -module()., -export(). etc, and function definitions, while in the shell you enter expressions to be evaluated. A...
View ArticleAnswer by Daniel Luna for Erlang getting error ** 1: syntax error before:...
You can't define functions in the shell using the same syntax as in an erl file. You can define fun's though. Syntax in the shell needs to be: Sum = fun([], _) -> 0; ([H | T], F) -> H + F(T, F)...
View ArticleErlang getting error ** 1: syntax error before: '->' **
I have started some hands on in Erlang and I am getting : ** 1: syntax error before: '->' ** whenever i am declaring any function for eg. to calculate sum of a list (this is experimental, of cource...
View Article