Re: n-dim matrices
[email protected] (Buddha Buck) Thu, 31 Aug 2000 12:27:20 -0400
| Newsgroups | perl.perl6.language.data |
|---|---|
| Message-ID | <[email protected]> |
At 12:09 PM 8/31/00 -0400, Karl Glazebrook wrote: >This is beginning to sound like something I would support. > >Heavens are we approaching some sort of consensus. The one thing the proposal I mentioned doesn't cover is Jeremy's desire to have $a[$i][$j][$j] be synonymous with $a[[$i,$j,$k]], and @a[$i,$x][$j,$y][$k,$z] be synonymous with @a[[$i,$j,$k],[$x,$y,$z]]. I didn't mention them because they aren't something I agree with, so it's not part of the compromise that I see. >This also addresses one pain in current PDL which is the >difficulty of multi-dim indexing. > >Buddha Buck wrote: <snip> > > print $a[[0,0,0]]; # literal ref list > > print $a[0;0;0]; # literal singleton ; list > > print $a[[$y,$y,$y]]; # variable-based ref list > > print $a[$y;$y;$y]; # variable-based singleton ; list > > print $a[[@lorigin]]; # ref to copy of array variable > > print $a[\@lorigin]; # ref of array variable > > print $a[$rorigin]; # ref variable > > print $a[diagonal(0)];# function that returns array ref > > > > There... 8 ways to do it... > >Do we really need 8 ways? Jeremy would add way 9 and 10... What was it Larry said about having 10 ways to do it? print $a[0][0][0]; print $a[$y][$y][$y]; To be fair, there is really only two (three) ways to do it: $a[0;0;0] and $a[[0,0,0]] (and $a[0][0][0]). The other seven are just ways to compute the listrefs needed at runtime. >Karl