Run-length encoding: Difference between revisions

Content added Content deleted
(Rescued TMG entry.)
Line 5,540: Line 5,540:
puts "success"
puts "success"
}</lang>
}</lang>

=={{header|TMG}}==
Unix TMG is designed to process and generate files rather than process text in memory. Therefore encoding and decoding parts can be done in separate programs.

Encoding:
<lang UnixTMG>loop: ordcop [lch?]\loop;
ordcop: ord/copy;
ord: char(ch)/last [ch!=lch?]\new [cnt++] fail;
new: ( [lch?] parse(out) | () ) [lch=ch] [cnt=1] fail;
out: decimal(cnt) scopy = { 2 1 };
last: parse(out) [lch=0];
copy: smark any(!<<>>);
ch: 0;
lch: 0;
cnt: 0;</lang>

Decoding:
<lang UnixTMG>loop: readint(n) copy\loop;
copy: smark any(!<<>>)
repeat: [n?] parse(( scopy )) [--n>0?]\repeat;
/* Reads decimal integer */
readint: proc(n;i) ignore(<<>>) [n=0] inta
int1: [n = n*12+i] inta\int1;
inta: char(i) [i<72?] [(i =- 60)>=0?];
i: 0;
n: 0;</lang>


=={{header|TSE SAL}}==
=={{header|TSE SAL}}==