Erlang basic syntax error -


i try learn erlang. i've installed runtime cannot working. following code:

x=3. 

works, following doesn't

 f(x)->x. 

or

 f() ->0. 

or

 f([])->[]. 

etc. produce "1: syntax error before: '->'" tried "word_count" tutorial: http://www.ybrikman.com/writing/2012/11/04/seven-languages-in-seven-weeks-erlang/ , same error.

what wrong here?

in repl have use fun(...) -> ... end:

1> f = fun(x) -> x end. #fun<erl_eval.6.80484245> 2> f(42). 42 

if have code in file use c command:

1> c(word_count). {ok,word_count} 2> word_count:word_count([]). 0 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -