In general, if you want to apply u along a group of n of axes:

axis=: 2 : 0
u"(#n)@(n&|:)
)

This is I believe very close to the axis operator in APL if you are familiar 
with it:

   ]m=: i.2 3 4
 0  1  2  3
 4  5  6  7
 8  9 10 11

12 13 14 15
16 17 18 19
20 21 22 23
   < axis 0 m
+----+----+-----+-----+
|0 12|1 13|2 14 |3 15 |
+----+----+-----+-----+
|4 16|5 17|6 18 |7 19 |
+----+----+-----+-----+
|8 20|9 21|10 22|11 23|
+----+----+-----+-----+
   < axis 1 m
+--------+--------+--------+--------+
|0 4 8   |1 5 9   |2 6 10  |3 7 11  |
+--------+--------+--------+--------+
|12 16 20|13 17 21|14 18 22|15 19 23|
+--------+--------+--------+--------+
   < axis 2 m
+-----------+-----------+-----------+
|0 1 2 3    |4 5 6 7    |8 9 10 11  |
+-----------+-----------+-----------+
|12 13 14 15|16 17 18 19|20 21 22 23|
+-----------+-----------+-----------+
   < axis 0 1 m
+--------+--------+--------+--------+
| 0  4  8| 1  5  9| 2  6 10| 3  7 11|
|12 16 20|13 17 21|14 18 22|15 19 23|
+--------+--------+--------+--------+
   < axis 0 2 m
+-----------+-----------+-----------+
| 0  1  2  3| 4  5  6  7| 8  9 10 11|
|12 13 14 15|16 17 18 19|20 21 22 23|
+-----------+-----------+-----------+
   < axis 1 0 m
+----+----+-----+-----+
|0 12|1 13| 2 14| 3 15|
|4 16|5 17| 6 18| 7 19|
|8 20|9 21|10 22|11 23|
+----+----+-----+-----+

In particular, you want

   < axis 0 i.5 2
+---------+---------+
|0 2 4 6 8|1 3 5 7 9|
+---------+---------+

Cheers,
Louis

> On 25 Aug 2017, at 05:54, bill lam <[email protected]> wrote:
> 
>   <"1 |: B
> +-------+-------+
> |0 2 4 6|1 3 5 7|
> +-------+-------+
> 
> if this is not what you wanted, then try
> 
>   <@,."1 |: B
> +-+-+
> |0|1|
> |2|3|
> |4|5|
> |6|7|
> +-+-+
> 
> 
> -- 
> regards,
> ====================================================
> GPG key 1024D/4434BAB3 2008-08-24
> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to