This is beginning to sound like something I would support.

Heavens are we approaching some sort of consensus.

This also addresses one pain in current PDL which is the
difficulty of multi-dim indexing.

Buddha Buck wrote:
> 
> Here is a quick summary of the proposal:
> 
> In the raw, arrays can be indexed by two things:  ints and refs to lists of
> ints.  If it's an int it's treated as a standard 1-D array.  If it's a ref,
> it's treated as a N-dim matrix, with N being the lengths of the reffed
> array.  So the following will work:
> 
> @points = ([0,0,0],[0,0,1],[0,1,1],[0,1,0],[1,1,0],[1,1,1],[1,0,1],[1,0,0]);
> 
> for (my $i=0;i<@points;i++) {
>    $matrix[$points[$i]] = $i;
> }
> print @matrix[@points];  # prints 12345678
> 
> Arrays could also be of the form:  @a[list1;list2], where the resulting
> array is formed by taking the cartesian product of list1 and list2 as
> indices into @a, allowing for a different style of slicing than is (easily)
> possible with the list-ref notation.  As a special optimisation, if all the
> ;-separated lists are singleton lists, then you get a scaler result.  That
> means that all of the following are equivilant:
> 
> sub diagonal ($) {
>    my $x = shift;
>    return [$x,$x,$x];
> }
> $y = 0;
> $rorigin = [0,0,0];
> @lorigin = (0,0,0);
> 
> 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?

Karl

Reply via email to