This channel is intended for people just starting with the Raku Programming Language ( Logs are available at
Set by lizmat on 8 June 2022.
01:19 discord-raku-bot left, discord-raku-bot joined 02:02 razetime joined 02:36 Kaipei left 03:32 razetime left 03:50 camelia left 03:54 camelia joined 03:57 Kaiepi joined 03:58 guifa_ left 03:59 guifa joined 04:03 gfldex joined 04:04 samebchase joined 04:16 tbrowder left, tbrowder joined 04:32 thowe left, elcaro left, destroycomputers left, elcaro joined, thowe joined 04:35 destroycomputers joined, razetime joined 04:51 razetime left 05:02 Heptite left 05:08 razetime joined 05:09 Kaiepi left 06:11 razetime left 06:12 razetime joined 06:38 destroycomputer- joined 06:39 destroycomputers left 06:55 razetime left 07:20 razetime joined 08:54 Kaiepi joined 09:03 razetime left 09:23 razetime joined 10:27 habere-et-disper joined
deadmarshal I want to write the equivalent of the Perl code in Raku. 11:36
Nemokosch deadmarshal: I feel I'm missing the end of the story 😛 11:40
deadmarshal It's for this challenge: 11:43
Nemokosch I mean... the end of the story. Did you hit a problem? 11:49
deadmarshal Throws this error: 11:52
Nemokosch oh okay, gotcha... 11:55
you need the brackets inside the map in the Raku example as well
that makes the scoping and passing of $_ work 11:56
deadmarshal Where should I put brackets? I'm sorry I'm bad at Raku 12:03
Nemokosch around the same thing as in Perl 🙂 12:05
what I'm not sure of is if the result will be the right result - but that's a different case and easier to tune anyway
deadmarshal hmm I wrote this:{[@A[$_..*-1], @A[0..$_-1]]}); It returns two Seq inside the array, but doesn't concat them 12:10
Nemokosch yeah well, not the right result but at least A result 😄 12:13
I don't want to say something stupid but I think the easiest way is to add | in front of the @, hence turning the result into a Slip 12:14
like `[|@A[$_..*-1], |@A[0..$_-1]]` 12:15
same as `slip @A[$_..*-1]` or `@A[$_..*-1].Slip` if you like those more 12:16
(not sure about the precedence of the subroutine version) 12:17
Kaiepi the sub needs parentheses somewhere in this case 12:19
if you're just flattening the slice away `|.skip($_), |.head($_)` might be a little cheaper 12:23
deadmarshal yep | works ;) 12:24
Nahita rotate is available if you wanted 12:31
deadmarshal Yes that would be better. I'll use that 12:38
13:56 razetime left 14:05 razetime joined
habere-et-disper I have some fundamental confusion over how to sort things. How do you sort the arrays in: 14:08
m: ( 8 => ['zebra', 'alpha'], 9 => ['zebra', 'beta'] )
camelia WARNINGS for <tmp>:
Useless use of "=>" in expression "9 => ['zebra', 'beta']" in sink context (line 1)
Useless use of "=>" in expression "8 => ['zebra', 'alpha']" in sink context (line 1)
habere-et-disper While keeping the structure. 14:09
It seems weird to have to restate the pair relationship with `=>` 14:18
m: say ( 8 => ['zebra', 'alpha'], 9 => ['zebra', 'beta'] ).map( { .key => .value.sort } )
camelia (8 => (alpha zebra) 9 => (beta zebra))
Nahita because you have a list of pairs 14:19
the container of pairs is of type `List`
and it doesn't induce the pair relationship on its element; they happen to be pairs 14:20
if you had a Hash, for example, then yes there's a pair relationship inherent 14:21
habere-et-disper Okay -- thanks! :-) 14:27
So how do I reverse the semantic order of:
m: .say for (1,2,3)
camelia 1
habere-et-disper I tried: 14:28
m: (1,2,3).map( *.say )
camelia 1
habere-et-disper But that produces an artifact.
Weird. I get: 14:29
> (1,2,3).map( *.say )
(True True True)
Nahita so `.map` will apply the function you pass to each and every element of the iterable; and whatever it returns, it will yield that back as the final, transformed iterable 14:32
habere-et-disper Thanks again -- helpful! :-) 14:33
Nahita so first `1.say` is performed; it prints 1 to STDOUT, and then returns True; and that True is what `map` will yield back at the end as the transformed result of 1 14:34
then `2.say` is performed; again, as a side effect, STDOUT sees 2; then True is returned, put to the result
and so on (although only 3 is left :p)
sorry i didn't understand to "reverse the semantic order of" part, and might as well have answered another thing. English not so good for me :\)
Nemokosch perhaps you could force sink context to map 14:36
m: sink (1, 2, 3).map(*.say)
Nahita shouldn't use map for the side effects
Nemokosch well it's a matter of style
habere-et-disper I was trying to turn the statement around from `.say for (1,2,3)` to `(1,2,3).say` but that's not quite right. 14:37
m: say (1,2,3).map( *.say ).sink
camelia 1
Nemokosch but yeah perhaps it's more conventional to just use a regular for 14:38
m: for (1, 2, 3) { .say }
Nahita (1, 2, 3).join("\n").say would address that
Nemokosch yeah well it depends a lot on what exactly you want to solve. If you just want to print values one under the other then surely, join and say is my favorite paradigm as well, perhaps it's the cleanest 14:40
if you want to execute method X on each element of a list, there is either `for @list { .X }` or `sink*.X)` but I'm not sure if the latter is properly optimized 14:42
so maybe it just discards the produced return value of map, I don't know
15:16 razetime left 15:25 razetime joined
Anton Antonov <@297037173541175296> Do you think posting here would make the bot propagate the message? 16:02
Nemokosch no, I don't think so
I think it's directly handled by an IRC bot
dunno which
Anton Antonov I tried to log in to the IRC, but is gives me errors...
Nemokosch yeah well, let me check from Pidgin 16:03
Anton Antonov Does anyone of you _beginners_ -- not just <@297037173541175296> -- use, or have used, podlite ? See : 16:04
16:21 habere-et-disper left 17:37 razetime left 17:43 Heptite joined
Superstart033 First time I heard about this 18:57
Anton Antonov I used it only a few times. I am not sure does it work on non-Apple OS'es. 19:19
Superstart033 I’ll try it once I get home, thanks for sharing it! 19:25
19:44 Ebudae joined 19:47 Heptite left