[Jprogramming] integer run length compression

'Pascal Jasmin' via Programming programming at jsoftware.com
Mon Jun 29 16:22:08 UTC 2015


pretty much the same as the rosettacode solution, but focused on an internal representation rather than outputting a string

torle =: (1 ,~ 2&(~:/\)) ({. , #);.2 ]
frle =: ([: ; <@#~/"1) :.torle



----- Original Message -----
From: Raul Miller <rauldmiller at gmail.com>
To: Programming forum <programming at jsoftware.com>
Cc: 
Sent: Monday, June 29, 2015 12:04 PM
Subject: Re: [Jprogramming] integer run length compression

Perhaps http://rosettacode.org/wiki/Run-length_encoding#J

Thanks,

-- 
Raul


On Mon, Jun 29, 2015 at 11:55 AM, John Baker <bakerjd99 at gmail.com> wrote:
> 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
> bakerjd99 at gmail.com
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


More information about the Programming mailing list