RosettaCodeData/Task/Run-length-encoding/Ursala/run-length-encoding.ursala
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

16 lines
283 B
Text

#import std
#import nat
encode = (rlc ==); *= ^lhPrNCT\~&h %nP+ length
decode = (rlc ~&l-=digits); *=zyNCXS ^|DlS/~& iota+ %np
test_data = 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW'
#show+
example =
<
encode test_data,
decode encode test_data>