Anonymous user
Huffman coding: Difference between revisions
m
→{{header|zkl}}: update
(Added Kotlin implementation) |
m (→{{header|zkl}}: update) |
||
Line 5,796:
This code was adapted from Perl, Python and most of the other examples.
<lang zkl>fcn buildHuffman(text){ //-->(encode dictionary, decode dictionary)
ft:=
foreach c in (text){ ft[c]=ft.find(c,0)+1 } // leafs w/count
Line 5,815:
if(T.isType(i))return(Void.Void,i,self.fcn); i });
encodeTable:=tree.toDictionary(); // symbol:Huffman code
decodeTable:=encodeTable.pump(
return(encodeTable,decodeTable);
}</lang>
|