Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Matrix-transposition/Raku/matrix-transposition.raku
Normal file
22
Task/Matrix-transposition/Raku/matrix-transposition.raku
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
# Transposition can be done with the reduced zip meta-operator
|
||||
# on list-of-lists data structures
|
||||
|
||||
say [Z] (<A B C D>, <E F G H>, <I J K L>);
|
||||
|
||||
# For native shaped arrays, a more traditional procedure of copying item-by-item
|
||||
# Here the resulting matrix is also a native shaped array
|
||||
|
||||
my @a[3;4] =
|
||||
[
|
||||
[<A B C D>],
|
||||
[<E F G H>],
|
||||
[<I J K L>],
|
||||
];
|
||||
|
||||
(my $n, my $m) = @a.shape;
|
||||
my @b[$m;$n];
|
||||
for ^$m X ^$n -> (\i, \j) {
|
||||
@b[i;j] = @a[j;i];
|
||||
}
|
||||
|
||||
say @b;
|
||||
Loading…
Add table
Add a link
Reference in a new issue