Selecting an item on a specific axis can also be performed using compress (/ in 
APL, # in
J). 
dim <- (shape array)[Axis]             NB. dim =. Axis{$array
sel <- (-item-[]IO) rotate dim take 1  NB. sel =. (-item) |. dim{.1
+/[Axis] sel/[Axis] array              NB. sel #"((#dim)-Axis) array

This only works for a single item tho.

--- Mike Day <[EMAIL PROTECTED]> wrote:

> Not J-programming but...
> 
> Here's a simple "non-nested array" method, easily
> worked up into an APL function, which might do what
> you want. I think it generalises to a rank higher
> (or lower) than 3, but you'd best check.  I suggest
> you look at the APL*PLUS III definition of transpose, 
> which should allow you to do more along the same
> lines. 
> 
> (NB. I'm adding extra line-feeds to beat T/bird's
> line-wrapping)
> 
> Using Jim Weigang's transliteration of APL primitives.
> 
> Adding J expressions as this is the J prog group! 
> J's transpose is a bit different from APL's....
>      
>       NB. using APL index origin 1
>      
>       A <- 2 3 4 {rho} {iota} ! 4
> 
>       NB. J: A =. i. 2 3 4
> 
>       r <- (1-n) {rot} {iota} {rho} {rho} A
> 
>       NB. J: r =. n |. i. $ $ A NB. J origin 0
> 
>       rtA <- r {transpose} A 
> 
>       NB. J: rtA =. r |: A
> 
>       tAn <- (1{drop}{rho rtA) {rho} , rtA
>      
>       NB. J: tAn =. (, $~ ([EMAIL PROTECTED])) rtA
> 
> NB. tAn is the required sub-array, but might need transposing...
> 
>       An <- ({gradeup} (-1) {drop} r) {transpose} tAn
> 
>       NB. J: An =. (/: }. r) |: tAn
> 
> Mike
> 
> 
> Will Slade wrote:
> > Hello,
> >
> > I'm crossposting this in the Usenet APL group.
> >
> > I'm learning APL*PLUS III for work, and I have a question for you
> > experienced APLers.
> >
> > Lets say I have a matrix, A, with dimensions 2 3 4.
> >
> > A„2 3 4 ½ ¼!4
> >
> > I can return the first dimension of A like so: A[1;;]
> >
> > Is there a way to return the nth dimension of A without knowing what the
> > dimensions of A are? I'd like the flexibility to arbitrarily return 
> > the nth
> > dimension, but I don't know how to do this in APL, and the error messages
> > are a little cryptic for someone with my inexperience.
> >
> > Thanks,
> > Will
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



       
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for 
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow  
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to