The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Array::Transpose - Transposes a 2-Dimensional Array

SYNOPSIS

  use Array::Transpose;
  @array=transpose(\@array);

  use Array::Transpose qw{};
  @array=Array::Transpose::transpose(\@array);

Example:

  use Array::Transpose;
  use Data::Dumper;
  my $array=transpose([
                        [ 0  ..  4 ],
                        ["a" .. "e"],
                      ]);
  print Data::Dumper->Dump([$array]);

Returns

  $VAR1 = [
            [ 0, 'a' ],
            [ 1, 'b' ],
            [ 2, 'c' ],
            [ 3, 'd' ],
            [ 4, 'e' ]
          ];

DESCRIPTION

This package exports one function named transpose.

In linear algebra, the transpose of a matrix A is another matrix A' created by any one of the following equivalent actions:

  • write the rows of A as the columns of A'

  • write the columns of A as the rows of A'

  • reflect A by its main diagonal (which starts from the top left) to obtain A'

USAGE

  use Array::Transpose;
  @array=transpose(\@array);

METHODS

transpose

Returns a transposed 2-Dimensional Array given a 2-Dimensional Array

  my $out=transpose($in);  #$in=[[],[],[],...];
  my @out=transpose(\@in); #@in=([],[],[],...);

BUGS

SUPPORT

AUTHOR

    Michael R. Davis
    CPAN ID: MRDVT
    STOP, LLC
    domain=>stopllc,tld=>com,account=>mdavis
    http://www.stopllc.com/

COPYRIGHT

This program is free software licensed under the...

        The BSD License

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO