I am currently working on this class assignment, which is to create a btree in Erlang and create a function able to delete an Element on it. From my perspective I can't understand the error Erlang is returning me when trying to compile my code.btree.erl:211: syntax error before: 'end'
Which to my knowledge isn't true, but I must be wrong? I was suspecting that it lies in the nested if clause but I tried coding the nested if statement according to here Nested If Clause .
I suspect it might just be a tiny issue that I am too stressed/blind to see right now. Any help would be appreciated.
deleteBT(BTree = {ElementAtom,Height,Links,Rechts}, Element) ->
if
Element > ElementAtom ->
NeuRechts = deleteBT(Rechts, Element),
Hanoi = findHeight(NeuRechts, Links),
{ElementAtom,Hanoi,Links,NeuRechts};
Element < ElementAtom ->
NeuLinks = deleteBT(Links, Element),
Hanoi = findHeight(NeuLinks, Rechts),
{ElementAtom,Hanoi,NeuLinks,Rechts};
Element == ElementAtom ->
if
BTree == {ElementAtom, Height, Links,{}} -> Links;
BTree == {ElementAtom, Height, {},Rechts} -> Rechts;
BTree == {ElementAtom, Height, {},{}} -> {};
BTree == {ElementAtom, Height, Links,Rechts} ->
Kleinster = kLZahl(Rechts), %Findet uns die Kleinste Zahl vom übergebenen Baum
RechtsNeu = deleteBT(Rechts, Kleinster),
Hanoi = findHeight(RechtsNeu, Links),
{Kleinster, Hanoi, Links, RechtsNeu};
true -> -1
end;
true -> -1;
end.
1条答案
按热度按时间ua4mk5z41#
我在你的评论中看到你已经解决了这个问题。
尽管如此,我还是想借此机会向您推荐一种简单的方法,使用模式匹配和较少的if来改进代码: