Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Run-length-encoding/Logo/run-length-encoding.logo
Normal file
18
Task/Run-length-encoding/Logo/run-length-encoding.logo
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
to encode :str [:out "||] [:count 0] [:last first :str]
|
||||
if empty? :str [output (word :out :count :last)]
|
||||
if equal? first :str :last [output (encode bf :str :out :count+1 :last)]
|
||||
output (encode bf :str (word :out :count :last) 1 first :str)
|
||||
end
|
||||
|
||||
to reps :n :w
|
||||
output ifelse :n = 0 ["||] [word :w reps :n-1 :w]
|
||||
end
|
||||
to decode :str [:out "||] [:count 0]
|
||||
if empty? :str [output :out]
|
||||
if number? first :str [output (decode bf :str :out 10*:count + first :str)]
|
||||
output (decode bf :str word :out reps :count first :str)
|
||||
end
|
||||
|
||||
make "foo "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
|
||||
make "rle encode :foo
|
||||
show equal? :foo decode :rle
|
||||
Loading…
Add table
Add a link
Reference in a new issue