tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
19
Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno
Normal file
19
Task/Run-length-encoding/SNOBOL4/run-length-encoding.sno
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
* # Encode RLE
|
||||
define('rle(str)c,n') :(rle_end)
|
||||
rle str len(1) . c :f(return)
|
||||
str span(c) @n =
|
||||
rle = rle n c :(rle)
|
||||
rle_end
|
||||
|
||||
* # Decode RLE
|
||||
define('elr(str)c,n') :(elr_end)
|
||||
elr str span('0123456789') . n len(1) . c = :f(return)
|
||||
elr = elr dupl(c,n) :(elr)
|
||||
elr_end
|
||||
|
||||
* # Test and display
|
||||
str = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'
|
||||
output = str;
|
||||
str = rle(str); output = str
|
||||
str = elr(str); output = str
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue