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:12
tea3po left
00:13
tea3po joined
01:07
tea3po left
01:08
tea3po joined
01:22
MasterDuke joined
03:46
hythm joined
05:52
hythm left
07:55
dakkar joined
11:40
tea3po left,
tea3po joined
11:41
tea3po left
11:42
tea3po joined
|
|||
antononcube | Yeah, also known as the "ZOMG trick." | 14:14 | |
nemokosch | ZOMG - handle it! | 14:33 | |
tenor.com/view/bloons-bloons-td6-z...f-25688953 | |||
16:54
dakkar left
17:31
swaggboi left
17:39
swaggboi joined
|
|||
Dr.Doom | 0...^@a.elems amy shorter way of achiving the same ? | 18:05 | |
Nahita | ^@a | 18:11 | |
^ as a prefix operator eases writing ranges starting at 0 | 18:12 | ||
^$n is the same as 0..$n | |||
lizmat | 0..$n-1 | ||
not 0..$n | |||
Nahita | sorry | 18:13 | |
^$n is the same as 0..^$n | 18:14 | ||
lizmat | indeed :-) | 18:17 | |
Nahita | also idk if that's your intention or not but usually people don't iterate over those indices of 0 to array_length as we do in C. Rather the arrays themselves are iterable so the "foreach" loop is there like for @a -> $val { ... }. If one wants the indices still, there is @a.kv to give the "key"s of the array, i.e., 0 to $n-1 as well as the "value"s of the array, i.e., the elements themselves. Like for @a.kv -> | 18:26 | |
$idx, $val { ... }. Noting that .kv actually gives 2*$n length of a Sequence like (0, @a[0], 1, @a[1], ..., $n-1, @a[$n-1]) but the block attached to that for loop requests 2 things at a time, so this sequence is consumed 2 things at a time to work as expected. | |||
21:27
Tirifto left
21:35
Tirifto joined
22:39
krrishhrx joined
22:50
krrishhrx left
23:42
teatime joined
23:43
tea3po left
|