[Jprogramming] APL Question

Björn Helgason gosinn at gmail.com
Thu Jun 14 11:09:43 HKT 2007


J is totally free so you should have no problem upgrading.



2007/6/13, Will Slade <willhslade at gmail.com>:
>
> Hi,
>
> I got spanked for asking this in a J forum. Totally understandable. I
> think
> I have an answer; it's easier to do in modern APLs/J, but in the software
> I'm using at work, it isn't. That's fine, it's good to know that other
> people had the same question and fixed it, but that I'm using old
> software,
> I don't have the resources.
>
> Thanks,
> WIll
>
> On 6/13/07, Mike Day <mike_liz.day at tiscali.co.uk> wrote:
> >
> > Dan
> >
> > I think a single "item" is what he asked for;
> > your suggestion is preferable to mine as it's
> > more general, especially if he needs hyperplanes
> > other than the first. It also avoids transposes
> > which could be expensive in a real application.
> >
> > A problem might arise - does APL*PLUS III allow
> > the rank-reduction in the final step, +/[axis] ,
> > for a non-nested character or general nested
> > array? I expect it does.
> >
> > Dick Bowman observes that modern APLs offer
> > forms of selection other than eg [i;j;]. Dyalog
> > APL now allows
> >
> > item {squid} [axis] A
> >
> > APL*PLUS III may well have a similar mechanism.
> >
> > Perhaps Will would comment on our various
> > contributions before the powers that be shut
> > down this non-J thread. In particular, does
> > he need the J-language solutions?
> >
> > Mike
> >
> >
> > Dan Baronet wrote:
> > > 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 <mike_liz.day at tiscali.co.uk> 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 =. (, $~ (}.@$)) 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
> > >
> > >
> > >
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: gosinn at gmail.com
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming


Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans

góður kennari getur stigið á tær án þess að glansinn fari af skónum
          /|_      .-----------------------------------.
         ,'  .\  /  | Með léttri lund verður        |
     ,--'    _,'   | Dagurinn í dag                     |
    /       /       | Enn betri en gærdagurinn  |
   (   -.  |        `-----------------------------------'
   |     ) |        (\_ _/)
  (`-.  '--.)       (='.'=)
   `. )----'        (")_(")


More information about the Programming mailing list