Run-length encoding: Difference between revisions

Add ed example
(Added Uiua solution)
(Add ed example)
 
Line 2,344:
 
</syntaxhighlight>
 
=={{header|ed}}==
 
An important limitation: only handles repetitions of up to 9 times. Extending the algo for more is trivial, but beyond this example.
 
<syntaxhighlight lang="sed">
H
,p
g/\([a-zA-Z]\)\1\1\1\1\1\1\1\1/s//9\1/g
g/\([a-zA-Z]\)\1\1\1\1\1\1\1/s//8\1/g
g/\([a-zA-Z]\)\1\1\1\1\1\1/s//7\1/g
g/\([a-zA-Z]\)\1\1\1\1\1/s//6\1/g
g/\([a-zA-Z]\)\1\1\1\1/s//5\1/g
g/\([a-zA-Z]\)\1\1\1/s//4\1/g
g/\([a-zA-Z]\)\1\1/s//3\1/g
g/\([a-zA-Z]\)\1/s//2\1/g
,p
g/9\([a-zA-Z]\)/s//\1\1\1\1\1\1\1\1\1/g
g/8\([a-zA-Z]\)/s//\1\1\1\1\1\1\1\1/g
g/7\([a-zA-Z]\)/s//\1\1\1\1\1\1\1/g
g/6\([a-zA-Z]\)/s//\1\1\1\1\1\1/g
g/5\([a-zA-Z]\)/s//\1\1\1\1\1/g
g/4\([a-zA-Z]\)/s//\1\1\1\1/g
g/3\([a-zA-Z]\)/s//\1\1\1/g
g/2\([a-zA-Z]\)/s//\1\1/g
,p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ ed -s run-length.input < run-length.ed
Newline appended
aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa
5a6h7mu7i6a
aaaaahhhhhhmmmmmmmuiiiiiiiaaaaaa</pre>
 
=={{header|Elena}}==
110

edits