🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
[Coke] yo 03:57
El_Che ma 08:05
whatnext Hello all :) quick (quite basic) question: say I have a method I want to `wrap`, I can do `&mymethod.wrap({ ... })` - but how do I write this if `mymethod` is stored in `$variable` ? 12:04
El_Che m: sub foo() {say "FOO"}; my $bar = sub {print "BAR"; foo()}; $bar.wrap(&foo); bar 12:16
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
bar used at line 1. Did you mean 'bag', 'VAR'?
El_Che it works here :)
m: sub foo() {say "FOO"}; my $bar = sub {print "BAR"; foo()}; $bar.wrap(&foo); bar()
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
bar used at line 1. Did you mean 'VAR', 'bag'?
El_Che m: sub foo() {say "FOO"}; my $bar = sub {print "BAR"; foo()}; $bar.wrap(&foo); $bar() 12:18
camelia FOO
El_Che \o/
whatnext hm ok thanks El_Che - but how about if I don't want to write `my $bar = sub { ... }` but instead refer to an existing method 12:22
I mean the name of the method is stored in the variable, rather than the method itself 12:23
this is really a question about how to write `&{$method}` (except this doesn't work)
whatnext any ideas? :) 12:26
El_Che m: sub foo() {say "FOO"}; sub bar () {print "BAR"; foo()}; &<bar>.wrap(&foo); bar() 12:41
camelia BARFOO
whatnext ah wow brilliant... angle brackets eh? :) 12:42
thanks!
wait... isn't `&<bar>` same as `&bar` ie a literal? 12:44
El_Che it's quoted
m: sub foo() {say "FOO"}; sub bar () {print "BAR"}; my $baz = &bar; $baz.wrap(&foo); bar() 12:48
camelia FOO
El_Che lizmat is the one liner wizzard :)
whatnext m: sub foo(){ say "hello" }; my $bar = 'foo'; my $baz = &$bar; $baz.wrap({ say "bye"; callsame }); foo(); 12:55
camelia No such method 'wrap' for invocant of type 'Str'. Did you mean any of
these: 'Map', 'Rat', 'WHAT', 'grep', 'map'?
in block <unit> at <tmp> line 1
whatnext it's the `$baz = &$bar` part that I can't work out
El_Che one layer of indirection too many :) 12:56
I personally tend to use a dispatch table for that kind of stuff: 13:00
m: sub foo(){ say "hello" }; my %dtable = 'foo' => &foo; my $baz = 'foo'; %dtable{$baz}.wrap({say "bye"; callsame }); foo();
camelia bye
hello
whatnext that still involves writing the method as a literal though. Thanks for your help anyway El_Che :) 13:02
El_Che one can try 13:03
wait for the wizzard
s
Anton Antonov Is there are a "standard" name for the last evaluated result in REPL? (Something like `_` in Python or `%` in Mathematica.) 16:07
tbrowder g'day, rakuuns 16:33
how do i programmatically check for an installed 'fez'? 16:34
i've tried 'try require fez'
and 'try require Fez' 16:35
El_Che discord-raku-bot: Anton Antonov#7232: not that I know off, it's called a sink context in raku
docs.raku.org/language/contexts#Sink 16:36
tbrowder never mind, just found solution in docs i think (as i eat humble pie once more)... 16:43
Anton Antonov El_Che, Thank you! 16:59
tbrowder back again, it didn't work as expected. the library's name is 'fez' and provides several modules named Fez::*. 17:03
bummer, fumble fingers again...disregard all above... 17:10
ok, success. i tested for: try require ::("Fez::CLI"); die if ::("Fez::CLI") ~~ Failure; 17:21
whew! 17:22
marcbr Hi Raku developers . At first, I would like to congratulate for the great work. I would like to know what are advantages of Raku over Python mainly if Raku has GIL like python. Do you think that Rku could have a good numerical library as numpy for scientific application such as AI/ML? 17:52
I main job is work with ML/DL in python. I would like to see more Raku in the area. What d  you think? It is work while?
codesections Huh, another day, another Raku Advent calendar post on the hacker news front page. Congrats, pheix! 17:57
El_Che (s)he left :) 18:06
Anton Antonov I have a list of arrays, say, `$dfGrouped` and join them into one array with ` $dfGrouped.reduce( -> $x, $y { [|$x, |$y] } )`. Is there are shorter, more elegant way of doing that? 18:30
codesections [$dfGrouped.flat] 18:43
ggoebel marcbr: raku does not have a GIL like python. It has parallelism, concurrency, and asynchrony baked in. www.youtube.com/watch?v=JpqnNCx7wVY 18:57
tellable6 ggoebel, I'll pass your message to marcbr
tbrowder marcbr: but there is a thread on per6users about getting some raku ppl together to work on something similar 19:03
tellable6 tbrowder, I'll pass your message to marcbr
Anton Antonov codesections Thank you! 20:05
codesections -- `[$dfGrouped.flat]` actually, this does not work for me. 20:11
ggoebel m: [[0,1],[2,3],[4,5]>>.List.flat.say 23:15
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in array composer; couldn't find final ']' (corresponding starter was at line 1)
at <tmp>:1
------> 3[[0,1],[2,3],[4,5]>>.List.flat.say7⏏5<EOL>
expecting any o…
ggoebel m: [[0,1],[2,3],[4,5]]>>.List.flat.say
camelia (0 1 2 3 4 5)
merryprog you'd think a flat list would have square brackets, not parentheses... 23:16
(Sorry)
ggoebel m: my $dfGrouped = [[0,1],[2,3],[4,5]]; $dfGrouped>>.List.flat.say 23:31
camelia (0 1 2 3 4 5)
gfldex dd [[0,1],[2,3],[4,5]].duckmap: |*; 23:32
m: dd [[0,1],[2,3],[4,5]].duckmap: |*;
camelia Array element = [0, 1, 2, 3, 4, 5]
ggoebel nice 23:36