0
我只是找出控制流,它的一切非常奇怪和困惑,因为我以前从未使用过函数式语言,可能会有人纠正这对我来说:返回true或false发现串
-export([main/1, test/2]).
main([]) ->
if
test("blue yellow green", "yellow") == true ->
{io:fwrite("found")};
true ->
{io:fwrite("not found")}
end.
test(Source, Find) ->
Pos = string:str(Source, Find),
if
Pos > 1 ->
{true};
true ->
{false}
end.
我可能会使用'case string:str(Source,Find)of P when P> = 1 - > true; 0 - > false end'或类似的东西 –
甚至只是'string:str(Source,Find)> = 1.' – rvirding