[Jprogramming] Array Coordinates

Don Guinn donguinn at gmail.com
Fri Nov 30 19:03:32 UTC 2018


Or do
 4 $.$.a
On Fri, Nov 30, 2018, 11:56 AM Roger Hui <rogerhui.canada at gmail.com wrote:
> a #&, {i.&.>$a
> ┌───┬───┬───┬───┬───┐
> │0 0│2 3│4 6│6 9│9 2│
> └───┴───┴───┴───┴───┘
> > a #&, {i.&.>$a
> 0 0
> 2 3
> 4 6
> 6 9
> 9 2
>>>> On Fri, Nov 30, 2018 at 10:52 AM Skip Cave <skip at caveconsulting.com>
> wrote:
>> > Given the array a:
> >
> > ]a=.10 100ドル=23|i.100
> >
> > 1 0 0 0 0 0 0 0 0 0
> >
> > 0 0 0 0 0 0 0 0 0 0
> >
> > 0 0 0 1 0 0 0 0 0 0
> >
> > 0 0 0 0 0 0 0 0 0 0
> >
> > 0 0 0 0 0 0 1 0 0 0
> >
> > 0 0 0 0 0 0 0 0 0 0
> >
> > 0 0 0 0 0 0 0 0 0 1
> >
> > 0 0 0 0 0 0 0 0 0 0
> >
> > 0 0 0 0 0 0 0 0 0 0
> >
> > 0 0 1 0 0 0 0 0 0 0
> >
> >
> > How can I write a function 'ac' that will list the coordinates of each 1
> in
> > the array?
> >
> > Example using array a:
> >
> > ac a
> >
> > 0 0
> >
> > 2 3
> >
> > 4 6
> >
> > 6 9
> >
> > 9 3
> >
> > Extend to 3 or more dimensions?
> >
> > Skip Cave
> > ----------------------------------------------------------------------
> > 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

AltStyle によって変換されたページ (->オリジナル) /