huff_compress.src
content = get_shell.host_computer.File(home_dir+"/code.src").get_content
v = content.values
p = v.indexes[-1]
nb = 0
count = []
while v.len > 0
count.push(code(v.pull))
end while
table = {}
nb = 0
while count.len > 0
value = count.pull
if not table.hasIndex(value) then
nb = 1
table[value] = nb
end if
if table.hasIndex(value) then
nb = table[value] + 1
table[value] = nb
end if
end while
wordcount = []
nb = -1
for c in range(9999,0)
for ct in table.indexes
if table[ct] == c then
nb = nb + 1
wordcount.push(nb+":"+ct)
end if
end for
end for
print("Character table (sorted by frequency):")
print(wordcount.join(";"))
print()
v = content.values
result = []
while v.len > 0
c1 = code(v.pull)
for x in wordcount
wc1 = x.split(":")[0]
wc2 = x.split(":")[1]
if typeof(wc1) != "number" then wc1 = wc1.val
if typeof(wc2) != "number" then wc2 = wc2.val
if typeof(c1) != "number" then c1 = c1.val
if c1 == wc2 then
result.push(wc1)
end if
end for
end while
print("Content:"+char(10)+result.join(";"))
print("Before: "+str(content.values.indexes[-1]))
print("After: "+str(wordcount.join(";").values.indexes[-1]+result.join(";").values.indexes[-1]))