Erlang中未定义的函数

58wvjzkj  于 7个月前  发布在  Erlang
关注(0)|答案(1)|浏览(103)

在编译时给出{ok,assignment 5}。

three_a(F) -> fun(Y) -> lists:foldl(F,0,Y).

字符串
写完这

F1=assignment5:three_a(fun(X,Sum) -> X+Sum end).


** exception error: undefined function assignment5:three_a/1


请帮帮忙!

jaql4c8m

jaql4c8m1#

所有funsanonymous functions)都以fun(.)开头,以end结尾。1
使用语法修复后,它将像这样工作:

1> three_a(F) -> fun(Y) -> lists:foldl(F,0,Y).
* 1:12: syntax error before: '->'
1> three_a(F) -> fun(Y) -> lists:foldl(F,0,Y) end.
ok
2> F1= three_a(fun(X,Sum) -> X+Sum end).
#Fun<erl_eval.42.125776118>
3>

字符串

相关问题