>>>>> "LP" == Luke Palmer <[EMAIL PROTECTED]> writes:
LP> On 5/18/05, Anthony Heading <[EMAIL PROTECTED]> wrote: >> Is there a way to target hyperoperators at different axes of a >> multi-dimensional array? This is an attractive feature of >> various APL-like languages, viz. e.g. in J: >> >> a =. 2 5 $ i. 7 - a simple 2-by-5 array >> a >> 0 1 2 3 4 - like this >> 5 6 0 1 2 >> >> >> +/"1 a - sum reduce over axis 1 >> 10 14 LP> [+]<< @a >> +/"2 a - sum reduce over axis 2 >> 5 7 2 4 6 LP> Can't think of any for this one. Or maybe it's this one that I can LP> think of it for, and the other one which I can't. i can't spit out the syntax but here is the conceptual way i would do it. we do have multidimensional slices so we could grab each slice (maybe with zip?) and pass that to [+] and then grab the list of results back into a array/matrix with one less dimension than the original. so it would be something like this: (very wacko pseudo code): @in[ * ; 2 ; * ] ==> map [+] ==> @out that was an (bad) attempt to slice the third entry in the second dimension to be summed. LP> I think we're beginning to re-invent PDL. Poorly. but is there a p6 pdl yet? they may not need much with multi-dim ops, slices, hyper and reduce all built in! also with type int (patform ints), they can get the dense storage needed (but losing any dimensional flexibility). uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org