2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -2,7 +2,7 @@ $ include "seed7_05.s7i";
const func string: lzwCompress (in string: uncompressed) is func
result
var string: result is "";
var string: compressed is "";
local
var char: ch is ' ';
var hash [string] char: mydict is (hash [string] char).value;
@ -17,19 +17,19 @@ const func string: lzwCompress (in string: uncompressed) is func
if xstr in mydict then
buffer &:= str(ch)
else
result &:= str(mydict[buffer]);
compressed &:= str(mydict[buffer]);
mydict @:= [xstr] chr(length(mydict));
buffer := str(ch);
end if;
end for;
if buffer <> "" then
result &:= str(mydict[buffer]);
compressed &:= str(mydict[buffer]);
end if;
end func;
const func string: lzwDecompress (in string: compressed) is func
result
var string: result is "";
var string: uncompressed is "";
local
var char: ch is ' ';
var hash [char] string: mydict is (hash [char] string).value;
@ -43,10 +43,10 @@ const func string: lzwDecompress (in string: compressed) is func
for ch range compressed do
if buffer = "" then
buffer := mydict[ch];
result &:= buffer;
uncompressed &:= buffer;
elsif ch <= chr(255) then
current := mydict[ch];
result &:= current;
uncompressed &:= current;
chain := buffer & current;
mydict @:= [chr(length(mydict))] chain;
buffer := current;
@ -56,7 +56,7 @@ const func string: lzwDecompress (in string: compressed) is func
else
chain := buffer & str(buffer[1]);
end if;
result &:= chain;
uncompressed &:= chain;
mydict @:= [chr(length(mydict))] buffer & str(chain[1]);
buffer := chain;
end if;