Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
27
Task/Run-length-encoding/SETL/run-length-encoding.setl
Normal file
27
Task/Run-length-encoding/SETL/run-length-encoding.setl
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
program rle;
|
||||
test := "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW";
|
||||
|
||||
print("Input:");
|
||||
print(test);
|
||||
print("Encoded:");
|
||||
print(enc := rlencode(test));
|
||||
print("Decoded:");
|
||||
print(rldecode(enc));
|
||||
|
||||
proc rlencode(s);
|
||||
loop while s /= "" do
|
||||
part := span(s, s(1));
|
||||
r +:= str #part + part(1);
|
||||
end loop;
|
||||
return r;
|
||||
end proc;
|
||||
|
||||
proc rldecode(s);
|
||||
loop while s /= "" do
|
||||
num := span(s, "0123456789");
|
||||
item := notany(s, "");
|
||||
r +:= val num * item;
|
||||
end loop;
|
||||
return r;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue