Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
Module RLE_example {
|
||||
inp$="WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||||
Print "Input: ";inp$
|
||||
Function RLE$(r$){
|
||||
Function rle_run$(&r$) {
|
||||
if len(r$)=0 then exit
|
||||
p=1
|
||||
c$=left$(r$,1)
|
||||
while c$=mid$(r$, p, 1) {p++}
|
||||
=format$("{0}{1}",p-1, c$)
|
||||
r$=mid$(r$, p)
|
||||
}
|
||||
def repl$
|
||||
while len(r$)>0 {repl$+=rle_run$(&r$)}
|
||||
=repl$
|
||||
}
|
||||
RLE_encode$=RLE$(inp$)
|
||||
Print "RLE Encoded: ";RLE_encode$
|
||||
Function RLE_decode$(r$) {
|
||||
def repl$
|
||||
def long m, many=1
|
||||
while r$<>"" and many>0 {
|
||||
many=val(r$, "INT", &m)
|
||||
repl$+=string$(mid$(r$, m, 1), many)
|
||||
r$=mid$(r$,m+1)
|
||||
}
|
||||
=repl$
|
||||
}
|
||||
RLE_decode$=RLE_decode$(RLE_encode$)
|
||||
Print "RLE Decoded: ";RLE_decode$
|
||||
Print "Checked: ";RLE_decode$=inp$
|
||||
}
|
||||
RLE_example
|
||||
Loading…
Add table
Add a link
Reference in a new issue