Huffman coding: Difference between revisions
Content added Content deleted
(→{{header|Lua}}: update description) |
m (→{{header|Tcl}}) |
||
Line 6,044: | Line 6,044: | ||
set encoding [walkTree [$pq get]] |
set encoding [walkTree [$pq get]] |
||
set map [dict create {*}[lreverse $encoding]] |
|||
if {$opts(-dump)} { |
if {$opts(-dump)} { |
||
foreach |
foreach {char huffCode} [lsort -index 1 -stride 2 -command compare $encoding] { |
||
puts "$char\t[dict get $charcount $char]\t$huffCode" |
|||
puts "$char\t[dict get $charcount $char]\t$key" |
|||
} |
} |
||
} |
} |
||
$pq destroy |
|||
return $encoding |
return $encoding |