Run-length encoding: Difference between revisions

Content added Content deleted
m (J: alternate implementation -- further cleanup (and rewrite))
m (Credit for others)
Line 1,695: Line 1,695:
=== Alternative Implementation ===
=== Alternative Implementation ===


A numeric approach, based on a discussion in the J forums:
A numeric approach, based on a discussion in the J forums (primarily [http://jsoftware.com/pipermail/programming/2015-June/042139.html Pascal Jasmin] and [http://jsoftware.com/pipermail/programming/2015-June/042141.html Marshall Lochbaum]):


<lang j> torle =: (#, {.);.1~ 1,2&(~:/\)
<lang j> torle =: (#, {.);.1~ 1,2&(~:/\)