У меня есть функция, которая постоянно выдает мне ошибку «codes/3 undefined». Вот код функции:
table(Sample)->
Freq=freq(Sample),
Tree = huffman(lists:keysort(2, Freq)),
codes(Tree).
codes(Tree)->
{_,_,X,_}=Tree, <---- Masks out a tuple
{Y,_,_,_}=Tree, <----- Masks out an atom
codes(X,Y,[]). <------ Here is where it gives error.
codes({},_,List)->List;
codes(Entry,Type,List)->
case Type of
leaf->
NewList=[element(3,Entry)|List];
node->
Entry1=element(2,Entry),
Entry2=element(2,Entry),
codes(Entry1,element(1,Entry1),List),
codes(Entry2,element(1,Entry2),List);
end.
Не могу понять почему, может кто знает?
EDIT: проблема была ;
после последней end
, а не .
, теперь исправлена.
syntax error before: 'end'
. Удалите последний;
. - person aronisstav   schedule 28.01.2015