Run-length encoding: Difference between revisions
Content added Content deleted
Line 2,201: | Line 2,201: | ||
? unrle(rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")) |
? unrle(rle("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")) |
||
# value: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"</syntaxhighlight> |
# value: "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"</syntaxhighlight> |
||
=={{header|EasyLang}}== |
|||
<syntaxhighlight lang="easylang"> |
|||
proc enc in$ . out$ . |
|||
out$ = "" |
|||
for c$ in strchars in$ |
|||
if c$ = c0$ |
|||
cnt += 1 |
|||
else |
|||
if cnt > 0 |
|||
out$ &= cnt & c0$ & " " |
|||
. |
|||
c0$ = c$ |
|||
cnt = 1 |
|||
. |
|||
. |
|||
out$ &= cnt & c0$ |
|||
. |
|||
proc dec in$ . out$ . |
|||
out$ = "" |
|||
for h$ in strsplit in$ " " |
|||
c$ = substr h$ len h$ 1 |
|||
for i to number h$ |
|||
out$ &= c$ |
|||
. |
|||
. |
|||
. |
|||
call enc input r$ |
|||
print r$ |
|||
call dec input r$ |
|||
print r$ |
|||
# |
|||
input_data |
|||
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW |
|||
12W 1B 12W 3B 24W 1B 14W |
|||
</syntaxhighlight> |
|||
=={{header|Elena}}== |
=={{header|Elena}}== |