Nathan Wiger wrote:
> Let me make an observation, having done tons of matrix stuff: We're
> going to wind up with 200 functions, all of which essentially are doing
> special types of matrix operations.
>
> How about a matrix-like set of functions that interleaves and
> un-interleaves stuff however you like?
>
>    matrix x2, @a, @b, @c;   # interleave every 2
>    unmatrix 3x2 @array;     # 3x2 list groupings
>
My hope is that RFC 81: 'Lazily evaluated list generation functions'
achieves this. It provides a flexible mechanism for creating a lazily
evaluated list, with shortcuts for creating simple slices. Amongst other
things, these generated lists can be used as indices to lists in order to
extract a subset of them. From the RFC:

<quote>
This slicing notation is particularly useful for dealing with arrays,
matrices, and tensors:

  @matrix = (1,3,4,
             2,6,7);
  @column1of3 = (1..10000:3);   # (1,4,7,...10000)
  print sum(@matrix[@column1of3]);          # Prints 3
  @matrix2 = readBig3ColumnMatrixFromSomewhere();
  $column1Sum = sum(@matrix2[@column1of3]); # No need to redefine our slice!
</quote>

Of course, if we allowed infinite lists, we wouldn't need this artificial
upper bound on @column1of3 <grumble, grumble...>

Still, your matrix/unmatrix idea is intruiging... I'd be interested to see
this fleshed out further (particularly to n-dimensional tensors, which is
where I find generic functions hard to specify)...


Reply via email to