klebs @Coke gotcha -- thank you everybody! -- it is all clear to me now 🙂 01:20
how do we write something like this? ```raku 02:10
my @arr = <
sub get-lines($fname) {
my @counts = @arr>>.get-lines;
say @counts;
basically, what i mean to do is apply some function as a transformation to each member of the array
until now, i have been writing a "do for" 02:12
my @counts = do for @arr {
i have a feeling there is a shorthand for this -- does anybody know what it is? 02:13
A26F64 Would `@arr.map({ get-lines($_) });` not be appropriate? 02:17
klebs thanks, it is definitely an upgrade -- there is something in the back of my mind i think i have seen somewhere which is one line, may use >> and does not explicitly need $_ 02:36
[Coke] @arr.map(*.get-lines) 02:39
slightly shorter; uses a whatevercode instead of a block.
A26F64 That's very clean but it fails for me as `get-lines` is not a method of Str. `@arr.map(*.IO.lines.elems)` should work (but that's not calling an independent function as requested). 02:47
02:51 mjgardner left 03:05 mjgardner joined 03:18 mjgardner left 03:21 mjgardner joined
avuserow Something like `@arr.>>&get-lines` ? 03:33
Something like `@arr>>.&get-lines` ? 03:34
A26F64 And by which means `@arr.map(*.&get-lines)` also works. 03:36
(Though the hyper operators are not strictly equivalent to ordinary `.map` as "all hyper operators are candidates for parallelism".) 03:44
04:03 mjgardner left 04:04 mjgardner joined 04:22 A26F64 left 06:04 gfldex left 06:05 gfldex joined 06:12 CIAvash left, codesections left 06:13 codesections joined 06:16 CIAvash joined
Morfent you shouldn't need the `WhateverCode` in this case: `@arr.map(&get-lines)` 06:45
klebs oh nice! thanks everybody for the answers. i'll be able to use bits and pieces of your replies for lots of new code (to be written) 🙂 07:35
!!! i think the syntax i had in the back of my mind used the &
i think the syntax i had in the back of my mind used the ampersand! that, i think, is the cleanest way 07:36
but the whatever code inside the map is also a great trick i didn't know
you folks are the best 🙂
i love that i can use this syntax with [+] to reduce the array 07:39
ie ``` say [+] @arr>>.&get-lines;```
brilliant syntax. raku is the best. 07:40
08:54 dakkar joined 13:42 melezhik joined, melezhik left 14:42 melezhik joined 15:25 melezhik left 16:04 A26F64 joined 17:36 dakkar left
lizmat and yet another Rakudo Weekly hits the Net: rakudoweekly.blog/2021/11/08/2021-...wo-commas/ 20:04
20:28 A26F64 left
Quibono Hello. 21:09
Is there any information related to how the grammars work 21:11
Ah nvm I found the page for them. 21:12