【发布时间】:2018-12-12 12:20:26
【问题描述】:
我正在尝试自学一些 erlang,但我不断收到我不理解的错误。
我正在尝试制作一个接受整数 N 并打印“Hello World”N 次的函数,这样我就可以热交换消息(还没有到达那部分)。
我的代码:
-module(repeater).
-export([repeat/1], [start/0]).
repeat(Num) when is_Integer(Num), Num > 0 ->
if Num == 1 ->
io:fwrite("Hello World"),
io:fwrite("~n");
else ->
io:fwrite(pass(Num - 1));
true ->
io:fwrite("I have no idea what is happening")
end.
start() ->
repeat(3).
我得到的错误信息是:
repeater.erl:7: bad export declaration
repeater.erl:11: Warning: function pass/1 is unused
repeater.erl:21: Warning: function start/0 is unused
我不知道为什么它说它是“未使用”。
我发现这种语言很难为自己学习,因为我什至无法让 if else 块正常工作
【问题讨论】: