rle: run-length encoding
_rle_: run-length encoding
Index terms: _rle_ _rle.ss_ _rle.plt_
This is a basic implementation of the standard run-length encoding
algorithm.
Example
-------
> (require (planet "rle.ss" ("dyoo" "rle.plt") 1))
> (rle-encode "110101000111")
((2 #\1) (1 #\0) (1 #\1) (1 #\0) (1 #\1) (3 #\0) (3 #\1))
> (rle-decode (rle-encode "110101000111"))
"110101000111"
That pretty much sums it up.
API
---
> rle-encode: string -> (listof (list number char))
Returns a list of (number char) sublists representing the run-length
encoding of a-string.
> rle-decode: (listof (list number char)) -> string
Does the inverse of rle-encode: takes a run-length encoding and rehydrates
the string.