我正在
syntax error before: 'end'
我每次都为分配运行此代码:
closest(_P, _PointList) ->
case (length(_PointList =:= 0)) of
true -> {0,0};
false -> closest(_P, tl(_PointList), distance(_P, hd(_PointList)), 1)
end.
% Llength = length(_P),
closest(P, _PointList, _Distance, _Index) ->
case (length(_PointList =:= 0)) of
true -> {_Index, _Distance};
false ->
New_Distance = min(_Distance, distance(_P, hd(_PointList)),
case (New_Distance < _Distance) of
true -> closest(_P, tl(_PointList), New_Distance, _Index + 1);
false -> closest(_P, tl(_PointList), _Distance, _Index)
end
end
end.
有人可以帮我弄清楚为什么会这样吗?感谢
答案 0 :(得分:2)
错过了)
的{{1}}并且有额外的min/2
应该是:
end
答案 1 :(得分:0)
你可能想写这个:
closest(_P, []) -> {0, 0};
closest(P, [H|T]) ->
closest(P, T, distance(P, H), 0, 1).
closest(_P, [], Distance, ClosestIndex, _Index) ->
{ClosestIndex, Distance};
closest(P, [H|T], Distance, ClosestIndex, Index) ->
case distance(P, H) of
New_Distance when New_Distance < Distance ->
closest(P, T, New_Distance, Index, Index + 1);
_ ->
closest(P, T, Distance, ClosestIndex, Index + 1)
end.
答案 2 :(得分:0)
这看起来很可疑
case (length(_PointList =:= 0)) of
应该是
case length(_PointList) =:= 0 of
此外,您应该获得发现错误(或附近)的行号。错误堆栈跟踪肯定有帮助。