Wouldn't a sparse array be the perfect fit for this? a =: 0 0 0 0 0 0 2 4 4 4 4 2 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 2 b =: $. a Perhaps I'm missing something...
> Date: Mon, 29 Jun 2015 10:55:00 -0500 > From: [email protected] > To: [email protected] > Subject: [Jprogramming] integer run length compression > > I vaguely remember reading forum traffic sometime ago about a simple > J based run length encoding verb for integers. > > eg: > > If you have list of integers with many runs of the same value. > > 0 0 0 0 0 0 2 4 4 4 4 2 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 2 > 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > > What's a good way to compress, and decompress, this using only J? > > Just thought I would ask before rolling my own. > > -- > John D. Baker > [email protected] > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
