Jump to content

Run-length encoding: Difference between revisions

m (→‎{{header|REXX}}: added wording to the REXX section header.)
Line 2,166:
 
integer, parameter :: bufsize = 100 ! Sets maximum size of coded and decoded strings, adjust as necessary
character(bufsize) :: teststr = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
character(bufsize) :: codedstr = "", Encodedecodedstr (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)
Line 2,235 ⟶ 2,221:
end subroutine
end program</lang>
 
Output:
<pre>
12W1B12W3B24W1B14W
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW
</pre>
 
=={{header|FreeBASIC}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.