in reply to Two handy tools for nested arrays: mapat and transpose

Great article (++).

I'd love to see this implemented in OO-style, with mapat ,transpose and matrixwise methods.

It should also be possible to provide an OO general function to be performed on matrix elements, by passing in a reference to the function/sub.

Yes - I'm too lazy to do this, and do not have an immediate need.

    ...each is assigned his own private delusion but he cannot see the baggage on his own back.

  • Comment on Re: Two handy tools for nested arrays: mapat and transpose

Replies are listed 'Best First'.
Re^2: Two handy tools for nested arrays: mapat and transpose
by diotalevi (Canon) on Dec 07, 2004 at 21:23 UTC

    This is interesting. What part of OO do you think applies to this? You could decide that you have an N-dimensional matrix object and give it the matrixwise and multiply-composed methods. What of the mapat and transpose methods? Perhaps you give the mapat method to a multiply-nested array object. Does any of this tacking on of additional names to the functions buy you anything?

    Would it be for the type conversion safety? Or is this just so that you can use the functions and still say you're using OO?

      The mapat method on a matrix object could give you a way to flatten it into an array. The transpose method could return a transposed matrix object, or transpose the current object in-place. but the real power would come from something like this:
      #assume $m1 and $m2 are matrix objects my $m3 = $m1->ApplyFunction(\&mysub, $m2); .... sub mysub{ my ($element1,$element2)=@_; return $element1 &#$((Some operation) $element2; }
      Makes for code simplicity.

          ...each is assigned his own private delusion but he cannot see the baggage on his own back.