tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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