Run-length encoding: Difference between revisions
Content added Content deleted
(+ blsq) |
|||
Line 384: | Line 384: | ||
</lang> |
</lang> |
||
<pre> 12W1B12W3B24W1B14W</pre> |
<pre> 12W1B12W3B24W1B14W</pre> |
||
=={{header|Burlesque}}== |
|||
<lang burlesque> |
|||
"WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" |
|||
=[{^^[~\/L[Sh}\m |
|||
</lang> |
|||
=={{header|C}}== |
=={{header|C}}== |
||
Line 1,168: | Line 1,174: | ||
integer, parameter :: bufsize = 100 ! Sets maximum size of coded and decoded strings, adjust as necessary |
integer, parameter :: bufsize = 100 ! Sets maximum size of coded and decoded strings, adjust as necessary |
||
character(bufsize) :: teststr = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" |
character(bufsize) :: teststr = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" |
||
character(bufsize) :: codedstr = "" |
character(bufsize) :: codedstr = "" Encode (Data (Index..Data'Last)); |
||
end; |
|||
end; |
|||
end if; |
|||
end Encode; |
|||
function Decode (Data : String) return String is |
|||
begin |
|||
if Data'Length = 0 then |
|||
return ""; |
|||
else |
|||
declare |
|||
Index : Integer := Data'First; |
|||
Count : Natural := 0; |
|||
begin |
|||
while Index , decodedstr = "" |
|||
call Encode(teststr, codedstr) |
call Encode(teststr, codedstr) |