This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:11 swaggboi left 00:26 swaggboi joined 02:42 hythm joined 04:26 hythm left 06:13 arkiuat joined 10:40 arkiuat left 11:46 teatwo left, teatwo joined 11:48 teatwo left, teatwo joined 13:36 tbrowder__ left, tbrowder__ joined 14:01 kjp left 14:35 kjp joined 15:43 kjp left 16:07 kjp joined 17:54 habere-et-disper joined
habere-et-disper Hello rakoons -- thanks for all the conference videos ! :-) 18:39
What's a clear way of swapping the rows and columns of a two-dimensional array ? It seems it gets messy fast: 18:40
m: my @a=[ [1,1,1],[2,2,2],[3,3,3] ]; say @a[ 0 .. @a.end ; $_ ] for 0 .. @a.head.end;
camelia (1 2 3)
(1 2 3)
(1 2 3)
nemokosch [Z] might work 18:49
the only concern would be whether it cares about containerization or not 18:50
let's see
m: my @a=[ [1,1,1],[2,2,2],[3,3,3] ]; say [Z] @a;
Raku eval ((1 2 3) (1 2 3) (1 2 3))
nemokosch maybe let's mix it up a bit more to see it better
m: my @a = (1..9).rotor; say @a; say [Z] @a; 18:51
Raku eval Exit code: 1 Cannot resolve caller infix:«<»(); none of these signatures matches: ($?) (\a, \b) (Real $a, Real $b) (Int:D $a, Int:D $b --> Bool) (int $a, int $b --> Bool) (Num:D $a, Num:D $b --> Bool) (num $a, num $b --> Bool) (Rational:D $a, Rational:D $b --> Bool) (Rational:D $a, Int:D $b --> Bool) (Int:D $a, Rational:D $b --> Bool) (Instant:D $a, Instant:D
$b --> Bool) (DateTime:D $a, DateTime:D $b --> Bool) (Date:D $a, Date:D $b --> Bool) (Version:D $a, Version:D $b) in block <unit> at main.raku line 1
nemokosch okay, this error message may be LTA...
m: my @a = (1..9).rotor(3); say @a; say [Z] @a; 18:52
Raku eval [(1 2 3) (4 5 6) (7 8 9)] ((1 4 7) (2 5 8) (3 6 9))
nemokosch looks good, no?
habere-et-disper Yes, thanks ! 👍 18:53
Round tripping works too: 18:56
m: [Z] [Z] ( (1,1,1), (2,2,2), (3,3,3) )
camelia Potential difficulties:
Useless use of [Z] in sink context
at <tmp>:1
------> <BOL>⏏[Z] [Z] ( (1,1,1), (2,2,2), (3,3,3) )
habere-et-disper m: say [Z] [Z] ( (1,1,1), (2,2,2), (3,3,3) )
camelia ((1 1 1) (2 2 2) (3 3 3))
19:34 MasterDuke joined 19:40 habere-et-disper left 19:41 rcmlz joined 20:38 rcmlz left
.ohnowendigo That [Z] trick is deep magic 22:51
nemokosch reducing with zipping 23:01
not sure if &zip has an appropriate signature
there is some difference with the decontainerisation... 23:02
m: my @a = (1..9).rotor(3); say @a; say zip @a; 23:03
Raku eval [(1 2 3) (4 5 6) (7 8 9)] (((1 2 3) (4 5 6) (7 8 9)))
nemokosch yeah...
next attempt: flattening the array into arguments 23:04
m: my @a = (1..9).rotor(3); say @a; say zip |@a;
Raku eval [(1 2 3) (4 5 6) (7 8 9)] (((1 2 3) (4 5 6) (7 8 9)))
nemokosch yeah I think this is good old containers getting in the way
m: my @a = (1..9).rotor(3); say @a; say zip @a.List;
Raku eval [(1 2 3) (4 5 6) (7 8 9)] ((1 4 7) (2 5 8) (3 6 9))
nemokosch seems a lot like that
for some reason, [Z] removes the containers for the elements of the Array, therefore it will do the right thing 23:05
23:46 tea3po joined 23:50 teatwo left