🦋 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.
00:08 reportable6 left 00:09 reportable6 joined 00:13 jrjsmrtn joined 01:13 reportable6 left, evalable6 left, linkable6 left, bisectable6 left, notable6 left, committable6 left, tellable6 left, releasable6 left, unicodable6 left, quotable6 left, statisfiable6 left, benchable6 left, greppable6 left, sourceable6 left, bloatable6 left, coverable6 left, nativecallable6 left, shareable6 left 01:14 bisectable6 joined, evalable6 joined, bloatable6 joined, sourceable6 joined 01:15 releasable6 joined, nativecallable6 joined, committable6 joined, statisfiable6 joined, benchable6 joined, notable6 joined 01:16 unicodable6 joined, coverable6 joined, reportable6 joined, quotable6 joined, tellable6 joined, shareable6 joined, greppable6 joined, linkable6 joined 01:18 Kaiepi left 01:19 Xliff joined 01:32 Kaiepi joined 02:24 Kaiepi left
Voldenet m: (^10).reduce({($^a), $^b}).flat.say 02:36
camelia (((((((((0 1) 2) 3) 4) 5) 6) 7) 8) 9)
Voldenet m: sub flatten($_) { $_ ~~ Iterable ?? |$_.map(&flatten) !! $_ }; (^10).reduce({($^a), $^b}).&flatten.say 02:38
camelia (0 1 2 3 4 5 6 7 8 9)
drakonis hm, coerce protocol? 03:14
03:24 linkable6 left, evalable6 left 03:25 evalable6 joined 03:27 linkable6 joined
Voldenet coerce protocol is pretty useful, but undocumented 04:02
m: class Hello { has $.i; multi method COERCE(Int() $i) { Hello.new(:$i) }}; sub x(Hello() $h) { say $h }; x("42") 04:03
camelia Hello.new(i => 42)
Voldenet this is as useful as undocumented
04:21 Kaiepi joined 05:21 evalable6 left, bloatable6 left, benchable6 left, unicodable6 left, nativecallable6 left, committable6 left, statisfiable6 left, linkable6 left, releasable6 left, greppable6 left, notable6 left, tellable6 left, reportable6 left, sourceable6 left, bisectable6 left, quotable6 left, coverable6 left, shareable6 left 05:22 unicodable6 joined, releasable6 joined, statisfiable6 joined, coverable6 joined, linkable6 joined, quotable6 joined, notable6 joined 05:23 nativecallable6 joined, tellable6 joined, benchable6 joined, greppable6 joined, committable6 joined, evalable6 joined 05:24 sourceable6 joined, shareable6 joined, bisectable6 joined, reportable6 joined, bloatable6 joined 06:07 reportable6 left 06:10 reportable6 joined 07:10 quotable6 left, coverable6 left, notable6 left, committable6 left, unicodable6 left, nativecallable6 left, releasable6 left, reportable6 left, tellable6 left, bloatable6 left, linkable6 left, statisfiable6 left, sourceable6 left, shareable6 left, bisectable6 left, greppable6 left, benchable6 left, evalable6 left 07:11 evalable6 joined, tellable6 joined, bloatable6 joined, greppable6 joined, coverable6 joined, releasable6 joined, reportable6 joined 07:12 sourceable6 joined, unicodable6 joined, linkable6 joined, quotable6 joined, nativecallable6 joined 07:13 bisectable6 joined, shareable6 joined, benchable6 joined, notable6 joined, committable6 joined, statisfiable6 joined 07:57 Sgeo left 08:30 jjido joined 08:52 nikhil left 09:37 jjido left 09:56 jjido joined 10:18 jjido left 11:15 saint- joined
saint- Hey! So I have a grammar which parses something as shown here andrewshitov.com/2018/10/31/a-simp...-grammars/ but I was wondering once I have the match object, how do I navigate through the parse tree? For example if I want to print out only all the "assignment" tokens or "expression" tokens in this example 11:16
tellable6 2021-12-16T11:06:00Z #raku <tbrowder> .ask ssaint what kind of mobile app do you want?
nine saint-: Match objects do the Positional and Associative roles, i.e. they can be used like they were arrays or hashes for accessing groups and sub-rules. E.g. $my-match<assignment> 11:22
m: say $*RAKU.compiler.version 11:23
camelia v2022.04.87.g.77.bc.03047
nine tbrowder: ^^^
saint- nine it seems though I can't access a second level group though 11:25
nine You mean sub-rules of ssignment? That would be $my-match<assignment><whatever>. Providing that whatever is actually a named rule/token/regex and that there is exactly one assignment in your match. 11:27
saint- nine What if there are multiple matches
I'll give you an example, one sec 11:28
www.toptal.com/developers/hastebin...properties This is my output 11:29
I want to just print "plainBlock" for example 11:30
All of them
Or "refBlock"
And this is my code: www.toptal.com/developers/hastebin...ceyeku.xml 11:31
Xliff \o
nine saint-: that'd be $match<block>[0]<plainBlock> 11:34
Xliff saint: Then it looks like you would use $match[$idx]<block><plainBlock> 11:35
saint- Oh thank you! And is there a way to print just the matched text and not the subsequent parse tree?
nine Or for all of them $match<block>.map(*<plainBlock>).grep(*.defined)
stringify the resulting match object: $match[$idx]<block><plainBlock>.Str 11:36
saint- Thanks a lot nine ! It's making sense now 11:40
Xliff What's the best way to tell if a match object is Associative or Positional, then? 11:41
tbrowder .tell nine thanks!
tellable6 tbrowder, I'll pass your message to nine
Xliff m: my token letter { \w }; my token word { <letter>+ }; my $m = "abcd efgh ijk" ~~ / <word>; $m.gist.say 11:42
camelia ===SORRY!===
Unrecognized regex metacharacter ; (must be quoted to match literally)
at <tmp>:1
------> + }; my $m = "abcd efgh ijk" ~~ / <word>⏏; $m.gist.say
Unable to parse regex; couldn't find final '/'
at <tmp>:1
------> …
Xliff m: my token letter { \w }; my token word { <letter>+ }; my $m = "abcd efgh ijk" ~~ / <word> /; $m.gist.say 11:43
camelia 「abcd」
word => 「abcd」
letter => 「a」
letter => 「b」
letter => 「c」
letter => 「d」
Xliff m: my token letter { \w }; my token word { <letter>+ }; my $m = "abcd efgh ijk" ~~ / <word>+ /; $m.gist.say
camelia 「abcd」
word => 「abcd」
letter => 「a」
letter => 「b」
letter => 「c」
letter => 「d」
Xliff m: my token letter { \w }; my token word { <letter>+ }; my $m = "abcd efgh ijk" ~~ m:g/ <word>+ /; $m.gist.say
camelia (「abcd」
word => 「abcd」
letter => 「a」
letter => 「b」
letter => 「c」
letter => 「d」 「efgh」
word => 「efgh」
letter => 「e」
letter => 「f」
letter => 「g」
letter => 「h」 「ijk…
tbrowder regarding the term 4pi thing, i can use it in scope as above but i'm trying to put it in a module and export it. i haven't been successful trying the usual syntax 11:46
m: constant term:<4pi> is export = 4*pi; 11:49
camelia ( no output )
11:50 discord-raku-bot left 11:51 discord-raku-bot joined
tbrowder well, so far so good, in my other effort i had the "is export" on the other side of the = 11:51
back to the modue ... Math::Trig 11:52
nope, had syntax right, i just couldn't read it successfully by using that module 12:01
i can try the direct reading qualifying it by name of module... 12:02
12:07 reportable6 left 12:09 reportable6 joined
saint- Could someone explain how $match<block>.map(*<plainBlock>) ? As in could someone point me to how * or . works in a routine 12:11
Been trying to find out where I can read how they work but haven't been able to yet
This example is more confusing -- say ('hello', 1, 22/7, 42, 'world').map: { .^name } 12:12
Okay I just figured out about the colon syntax, but yeah wondering about the . vs * 12:14
nine saint-: docs.raku.org/type/Whatever#index-...r-currying 12:21
tellable6 2022-06-05T11:41:53Z #raku <tbrowder> nine thanks!
tbrowder i tried using the EXPORT sub but no go, i give up :-(
nine tbrowder: if something is so hard, it's usually worth asking the question if what you want to do is even a good idea 12:22
saint- Thanks nine !
tbrowder nine: exactly, it's not worth the effort 12:23
thanks for the cold water 12:24
Anton Antonov I can find the roles of a class with $class.^roles , but it seems I cannot do that for a grammar, i.e. $grammar.^roles does not work. Is there some alternative that works for grammars? 12:26
nine m: grammar Foo { }; say Foo.^roles.elems 12:27
camelia 1
nine Looks like ^roles on grammars works just fine
Anton Antonov @nine Please try `say Foo.^roles` -- you will get the error "Cannot find method 'find_method' on object of type NQPParametricRoleHOW". 12:45
moritz but that's a problem with the stringifcation of the type names, not with .^roles 12:50
m: grammar Foo { }; say .^name for Foo.^roles;
camelia NQPMatchRole
12:57 Util left
Anton Antonov <@171354420292878346>tz Ok. Still, I cannot find the roles of a grammar using `.^roles` . 12:59
nine But you can? .^roles gives you the roles 13:00
You expect to be able to do specific things with those roles (like just stringify or gist them) you get and that's where you fail. 13:01
moritz I haven't read the full backlog... where's the code?
nine m: grammar Foo does Numeric { }; dd Foo.^roles.map(*.^name) 13:02
camelia ("Numeric", "NQPMatchRole").Seq
Anton Antonov @nine Ok. My mistake, `$grammar.^roles.map({ $_.^name })` works. 13:08
It looks same / similar observations apply when using `.^attributes` on grammars. 13:18
13:57 linkable6 left, evalable6 left 13:59 linkable6 joined
ecocode[m] Hello, I have 3 arrays with different quantity of items ie: A=[a1,a2,a3] , B=[b1,b2], C=[c1,c2,c3,c4]. I want to to generate an array containing all possible combinations like: [a1,b1,c1], [a1,b1,c2] ... [a3,b2,c4] 14:00
In this case, the order is not particularly important.
Since raku has a lot of operators, which one would be the cleaniest one ? Speed is not really important, code maintainablility is the main priority.
14:00 evalable6 joined
moritz why an operator and not just a function? 14:05
ecocode[m] because @result =@A x @B x @C would be sooo nice 😉 14:06
moritz but above you listed maintainablility as your main priority, not conciseness or beatuy :D 14:09
ecocode[m] and if it would be even more nicier if it was lazy
moritz laziness is orthogonal to operator vs. function 14:10
ecocode[m] yeah, you can forget about lazy as requirement 😉 but beauty is of course important, otherwise I would use Python 😉 14:12
moritz there are symbols for joins in Unicode 14:14
⟗ - U+027D7 - FULL OUTER JOIN
maybe a good option for this one?
full outer join is roughly what you want 14:15
ecocode[m] that gives an error 14:21
but found the solution ! `@a = @A X @B X @C` works
I wasn't far 😉
moritz m: sub infix:<⟗>($x, $y) {say $x + $y }; say 4 ⟗ 5 14:22
camelia 9
True
moritz m: sub infix:<⟗>($x, $y) {$x + $y }; say 4 ⟗ 5
camelia 9
moritz ah, so X already does what you want, great
ecocode[m] yeah 14:23
is X lazy ?
I think so, since it generates a sequence.. right ?
hmmm... nope it is not lazy... tested with `@a = 1..100 X 1..100 X 1..1000; say @a[^5]` takes forever 14:39
ugexe m: my $a := 1..100 X 1..100 X 1..1000; say $a[^5] 15:00
camelia ((1 1 1) (1 1 2) (1 1 3) (1 1 4) (1 1 5))
15:00 linkable6 left, evalable6 left 15:01 evalable6 joined 15:02 linkable6 joined
ecocode[m] ugexe: awesome ! thanks ! 15:02
15:38 Sankalp- joined 15:40 Sankalp left, Sankalp- is now known as Sankalp 16:21 jjido joined 17:10 mexen joined
Anton Antonov I apologize for these ignorant questions: [1] Is the the blog/site deathbyperl6.com developed/maintained by Nick Logan? [2] Is Nick Logan also ugexe? [3] Is Tony O'Dell publishing Raku packages under user name tony-o ? 17:26
ugexe yes to all of those 17:27
Anton Antonov I assume the answers to all these questions is "yes", but when writing references it is a good idea to double check. 17:28
@ugexe Thanks!
17:31 Sankalp left 17:32 Sankalp joined
gfldex tbrowder: please note: github.com/rakudo/rakudo/issues/4942 17:47
tbrowder gfldex: thanks for showing how to use the exported term, and for creating the issue. think the new AST branch can make it work? 17:51
gfldex I thing nobody tried to export a term before. 17:53
18:07 reportable6 left 18:08 reportable6 joined 18:42 Sgeo joined 18:49 Geth left, Geth joined
Xliff Has anyone here heard of FluidSynth? 19:01
perryprog Yeah 19:02
Though the context I know about it is from playing Doom I and II 19:03
tbrowder gfldex: just a thought, maybe there’s a unicode char that looks like an arabic digit but really isn’t that could fake the symbol for the constant
gfldex Rakudo knows all the numbers, no matter the language. 19:04
tbrowder m: constant iipi = pi*2 19:05
camelia ( no output )
gfldex m: say ١ + ٢; 19:06
camelia 3
tbrowder m: constant ivpi = 4*pi 19:07
camelia ( no output )
gfldex m: say Ⅰ+Ⅱ;
camelia 3
tbrowder m: constant ipi = pi; say ipi 19:08
camelia 3.141592653589793
Xliff perryprog: I have basic binds for Raku. I'm looking for sample code from other languages that I can port. Have any idea where I can look for something like that? 19:14
perryprog hmm
Xliff, github.com/coelckers/ZMusic might have something 19:15
tbrowder m: say “c\[109]” 19:27
camelia c[109]
tbrowder m: say “\c[109]” 19:29
camelia m
tbrowder m: say “\c[4,109]” 19:30
camelia m
tbrowder m: say “\c[109,110]” 19:31
camelia mn
tbrowder m: my $a = \c[109,110]; say $a 19:32
camelia ===SORRY!=== Error while compiling <tmp>
Undeclared routine:
c used at line 1
tbrowder m: my $a = “\c[109,110]”; say $a 19:33
camelia mn
tbrowder m: constant “\c[109,110]” = pi; say mn 19:35
camelia ===SORRY!=== Error while compiling <tmp>
Missing initializer on constant declaration
at <tmp>:1
------> constant⏏ “\c[109,110]” = pi; say mn
Xliff github.com/Xliff/raku-FluidSynth 19:53
perryprog: Thanks!
20:20 jjido left 20:26 jjido joined
coleman Does the middle CircleCI badge icon look broken for anyone else? The URL is valid for me, though. github.com/Raku/doc#official-docum...on-of-raku 20:49
perryprog Doesn't load for me either; the URL for the image is a 404 20:57
20:58 mexen left
Anton Antonov It looks like 360.zef.pm/index.json has only author IDs that start with "zef", e.g. "zef:Altai-man", "zef:amano.kenji", ... Is there a JSON file with other non-zef-prefixed author IDs? 21:07
Xliff What does this error mean:
===SORRY!=== Error while compiling /home/cbwood/Projects/p6-GtkPlus/lib/GTK/Box.pm6 (GTK::Box)
New type Stash for CompUnit::DependencySpecification is not a mixin type
jdv anyone else see something like this?: Cannot find method 'is_dispatcher' on object of type BOOTCode 21:21
21:23 lichtkind joined
jdv m: role A {}; A.new ~~ A:D; 21:33
camelia ===SORRY!===
Cannot find method 'is_dispatcher' on object of type BOOTCode
jdv i don't think that used to happen... 21:34
21:44 sena_kun left
jdv Anton: they are in a repo that zef looks at somewhere 21:47
probably here - github.com/ugexe/Perl6-ecosystems 21:48
vrurg: i'd guess you'd know the most about the thing i tripped on 21:50
s/role/class/ and its fine so roley or something...
Anton Antonov @jdv Thank you! 21:54
vrurg jdv: Yes, it's my "baby". :) Optimizer stuff. 21:58
jdv the ll exec looked beyond me 21:59
should i log a bug or is that known or what do you think?
vrurg jdv: It's about to be fixed now. 22:03
Pretty stupid bug as one branch is testing for a method availability whereas another branch of the same condition doesn't. 22:04
22:15 jjido left
jdv oh ok. thanks! 22:30
no rush. i can deal... 22:31
vrurg jdv: github.com/rakudo/rakudo/pull/4944 – as soon as it's all green. 22:32
23:15 evalable6 left, linkable6 left 23:16 evalable6 joined 23:17 linkable6 joined