07:52 dakkar joined
lizmat and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2024/09/30/2024-40-done-25/ 11:28
sjn nice 12:52
16:38 dakkar left 18:39 discord-raku-bot left, discord-raku-bot joined
timemelon does raku have any ki 20:38
like haskell's mapMaybe, taking a function which both transforms and decides whether to include the result 20:39
I've found that using an empty slip in a map does something similar, like .map({ condition ?? do-something-to($_) !! |() }) 20:40
but I was wondering if there's something already made for that 20:41
scullucs Combine .map and .grep? 20:45
m: <1 2 3 4>.grep(* %% 2).map(* ** 3) 20:47
Raku eval
scullucs m: say <1 2 3 4>.grep(* %% 2).map(* ** 3)
Raku eval (8 64)
lizmat m: .say for <1 2 3 4>.map: { $_ if $_ %% 2 } # timemelon 22:31
camelia 2
4
lizmat any condition that does not fire, produces the empty Slip
so, what I understand of ki, .map is basically that, depending on the code you put in the map 22:32
m: .say for <1 2 3 4>.map: { $_ * 2 if $_ %% 2 } # modifying the result if there is a match 22:33
camelia 4
8
scullucs Thanks lizmat 🙂 22:42
23:15 Chanakan left
timemelon that's exactly what I was after, ty! 23:26