When I started using J to solve puzzles I often ended up with a mullti-dimensional binary array where the coordinates of the ones were the solutions (no doubt a common experience). I wrote a clunky verb to extract them but later I found 'list_indices', from somewhere now lost, which was much better.
Now there is this, just 5 characters, remarkable! Regards, Rob. > On 11 Jan 2017, at 15:53, Skip Cave <[email protected]> wrote: > > Ben's approach using Sparse has a useful side: > > t > > 1 0 0 1 0 1 > > 0 1 0 0 1 0 > > 1 1 1 0 1 1 > > 1 1 0 1 1 1 > > > ix1 =: 4$.$. > > NB. list indices only where there is a 1. Binary array input > > > > ix1 t > > 0 0 > > 0 3 > > 0 5 > > 1 1 > > 1 4 > > 2 0 > > 2 1 > > 2 2 > > 2 4 > > 2 5 > > 3 0 > > 3 1 > > 3 3 > > 3 4 > > 3 5 > > > > Skip Cave > >> On Wed, Jan 11, 2017 at 9:44 AM, Raul Miller <[email protected]> wrote: >> >> Easy to fix, though: >> >> 4$.$. 1+i.3 4 >> >> -- >> Raul >> >> >> On Wed, Jan 11, 2017 at 7:06 AM, Ben Gorte - CITG >> <[email protected]> wrote: >>> >>>> Ben: >>>> 4$.$. i.3 4 NB. Unboxed using Sparse >>> >>> Btw, this produces indices for the non-zero elements of the array only, >> which is not according to your specs. >>> Sorry for that. >>> >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
