Не могу понять, почему функция Erlang не определена

У меня есть функция, которая постоянно выдает мне ошибку «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, а не ., теперь исправлена.


person Scatman_John    schedule 28.01.2015    source источник
comment
Очевидно, в этом коде есть еще одна ошибка: syntax error before: 'end'. Удалите последний ;.   -  person aronisstav    schedule 28.01.2015
comment
Ага, и это также решило мой вопрос! Спасибо.   -  person Scatman_John    schedule 28.01.2015


Ответы (1)


Несмотря на то, что кто-то другой решил вопрос, ниже приведена структура из erlang.

case Expr of
    Pattern1 [when GuardSeq1] ->
        Body1;
        ...;
    PatternN [when GuardSeqN] ->
        BodyN
end
person ripudaman flora    schedule 28.01.2015