Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,44 @@
F compress(uncompressed)
V dict_size = 256
V dictionary = Dict((0 .< dict_size).map(i -> (String(Char(code' i)), i)))
V w =
[Int] result
L(c) uncompressed
V wc = wc
I wc C dictionary
w = wc
E
result.append(dictionary[w])
dictionary[wc] = dict_size
dict_size++
w = c
I !w.empty
result.append(dictionary[w])
R result
F decompress([Int] &compressed)
V dict_size = 256
V dictionary = Dict((0 .< dict_size).map(i -> (i, String(Char(code' i)))))
V result =
V w = String(Char(code' compressed.pop(0)))
result = w
L(k) compressed
V entry =
I k C dictionary
entry = dictionary[k]
E I k == dict_size
entry = ww[0]
E
exit(Bad compressed k: k)
result = entry
dictionary[dict_size] = wentry[0]
dict_size++
w = entry
R result
V compressed = compress(TOBEORNOTTOBEORTOBEORNOT)
print(compressed)
print(decompress(&compressed))