nice Roger, thank you
I2D =: (#&, {@:(i.&.>)@$)
I2d =: $ ((] <.@% 1{[) <"1@,. ] |~ 1 { [) I.@,
30 timespacex 'I2D 23 | ~ i. 100 100'
0.00365213 5.86925e6
30 timespacex 'I2d 23 | ~ i. 100 100'
0.0162787 4.22317e7
________________________________
From: Roger Hui <[email protected]>
To: [email protected]
Sent: Friday, November 30, 2018 1:56 PM
Subject: Re: [Jprogramming] Array Coordinates
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 <[email protected]> wrote:
> Given the array a:
>
> ]a=.10 10$0=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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm