Run-length encoding: Difference between revisions
Content deleted Content added
added PowerShell |
→{{header|J}}: simplify and speed up rle |
||
Line 543: | Line 543: | ||
NB. Run-length encode and decode... |
NB. Run-length encode and decode... |
||
rle= |
rle=: ([: ; (":@# , {.)&.>)@((1 , }. ~: }:) <;.1 ]) |
||
rle 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' |
rle 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW' |
||
12W1B12W3B24W1B14W |
12W1B12W3B24W1B14W |
||
Line 551: | Line 551: | ||
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW |
WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW |
||
</lang> |
</lang> |
||
=={{header|Java}}== |
=={{header|Java}}== |
||
<lang java>import java.util.regex.Matcher; |
<lang java>import java.util.regex.Matcher; |