我有以下 Erlang 代码,当我尝试编译它时,它给出如下警告,但这是有道理的。函数需要两个参数,但我需要匹配“其他所有内容”而不是 x、y 或 z。
-module(crop).
-export([fall_velocity/2]).
fall_velocity(P, D) when D >= 0 ->
case P of
x -> math:sqrt(2 * 9.8 * D);
y -> math:sqrt(2 * 1.6 * D);
z -> math:sqrt(2 * 3.71 * D);
(_)-> io:format("no match:~p~n")
end.
crop.erl:9: Warning: wrong number of arguments in format call.
我在 io:format 之后尝试了一个匿名变量,但它仍然不开心。