🦋 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: ... | Logs can be inspected at colabti.org/irclogger/irclogger_log/raku
Set by lizmat on 1 May 2021.
kybr m: my $graph = -> $out, $freq = 440, $dur = 0.5, $amp = 0.6 { }; 03:48
camelia ( no output )
kybr Comma CT gives me a sort of linting warning: Cannot put positional parameter $dur after an optional parameter 03:49
this seems reasonable, but i'm curious why i don't get the warning when executing a script.
also, Comma has really gotten better. yay! 03:51
xinming_ Is there a built-in function to recursively process a hash/array? 08:41
I'm trying to change all hypen in the hash keys so the generated json can be useful to old codes. :-) 08:42
moritz there's deepmap, dunno if that helps you 08:43
xinming_ thx, Will check it 09:20
hmm, deepmap doesn't work on keys, I'll have to write one myself 09:21
lizmat xinming_ : if you are sure there will be no collisions between keys and values 09:32
you could maybe do something like:
my %ap{Any} = %hash.antipairs; my %changed = %ap.deepmap: { }; my %result = %changed.antipairs ? 09:34
meh, won't work with recursion, sorry for the noise
moritz gist.github.com/moritz/8ab4e598ec7...3efe4fc44f 09:54
xinming_ moritz: thx, Actually, I have another version I wrote, but not generic as your version. 10:02
moritz: termbin.com/j7jf 10:03
Mine
BTW, are there any differences between .list vs .List ? 10:04
leont Sometimes, yes 10:07
leont The former returns a Positional, it doesn't have to be a List 10:09
xinming_ leont: could you please illustrate? I know .List is convert the Positional to a List using type object, but what does the .list do then?
leont Most of the time they do the same though
E.g. Array.list returns itself, but Array.List returns a new list 10:10
Shaeto is it correct chat for general raku programming questions? 10:31
lizmat yes 10:34
Shaeto thank you :) Q: i use prototyped grammar token, is it possible to add ONE action handler for all proto :sym< > variants ? 10:35
lizmat moritz ^^ 10:38
Shaeto for example i have "test:sym<A> test:sym<B> etc tests" and want to process all matches using one action method 10:39
method test ($/) does not work 10:40
moritz Shaeto: I don't think so 10:53
Shaeto thank you moritz 11:21
Anton Hi! I would like to generate sentences from Raku grammars. I have seen a video and a slide deck by Jonathan Worthington on the subject (titled "What if....Perl 6 Grammars could Generate?"), but they are from 7-8 years ago. Searches with Google did not produce links to other relevant work. Maybe there are some other / new efforts for that problem 12:34
people in this forum know about?
sena_kun Anton, hi. There was such an initiative back then, I think, but it was less relevant for recent years and so was not developed actively. 12:36
Anton sena_kun Ok, thanks! 12:37
moritz maybe be easier after the RakuAST rework is finished 12:38
Anton moritz I was just going to ask about using AST! :) 12:38
moritz quicker :D 12:40
Anton I think that, in principle, I should be able to "traverse" the methods/rules of the grammar objects and pick a random rule branches. Is this viable and easy enough? 12:41
moritz once you can introspect your regexes sufficiently, yes
of course you also need to consider character classes
and quantifiers
Anton So, to be clear, right now there is no sufficient regex introspection? 12:45
moritz at least I wouldn't be aware of how to do it
Anton @moritz Ok, thanks! You opinion to means that I should stay away from doing this in Raku for awhile... (I assume you are the author of the book "Parsing with Perl 6 Regexes and Grammars".) 12:48
moritz you assume correctly
Anton :)  Ok. Great book -- very instructive! 12:48
moritz thanks, glad you liked it 12:49
in fact, it's the book I'm most proud of (and which has the lowest sell count of any of my books :D)
Anton Hmm... I do think the subject matter is great, but most people / developers are not that interested in subject. 12:50
*The subject matter of the book... 12:52
@moritz I would like to ask about a different type of work you did : ODE solvers. Do you plan to resume your work on this package? github.com/moritz/Math-Model 12:53
moritz Anton: not really, I consider that thing feature complete 12:54
Anton Ok, good to know! 12:55
moritz though if you would like to take it over, and expand it (maybe plug in different integrators?), I'd be open to such an idea
Anton @moritz Yes, I think that would be interesting. I would like Raku packages to do, say, epidemiological simulations. 12:56
Also, I plan to write a numerical integration framework in Raku. Please see: github.com/antononcube/Raku-Math-NIntegrate
moritz looks interesting 12:58
Anton @moritz Thanks! Please take a look in this Raku package that generates monadic pipelines for epidemiological simulations: github.com/antononcube/Raku-DSL-En...gWorkflows . Right now I hook that Raku package outcomes in R and Mathematica. As I said, I would to use ODE solvers in Raku. 13:01
*I would like to... 13:03
patrickb bisectable: "abcdefg".subst( / ( cde ) /, { say $0.encode.decode } ); 15:49
bisectable6 patrickb, Will bisect the whole range automagically because no endpoints were provided, hang tight
patrickb, Output on all releases: gist.github.com/1535d580ef0ea5711f...554fb5598f
patrickb, Bisecting by exit code (old=2021.03 new=2021.04). Old exit code: 1
patrickb, bisect log: gist.github.com/36be05e7a27269cf6c...e1fa4d02f1 15:50
patrickb, (2021-04-11) github.com/rakudo/rakudo/commit/57...121a64d99d
patrickb, Bisecting by output (old=2016.09 new=2016.10) because on both starting points the exit code is 1
patrickb, bisect log: gist.github.com/b3077eca7df1fb4522...e403951af2
patrickb, (2016-09-27) github.com/rakudo/rakudo/commit/22...0f14b9c05c
patrickb, Output on all releases and bisected commits: gist.github.com/45cabf1aa8e08062e3...3dcbc363dd
patrickb bisectable: "abcdefg".subst( / ( cde ) /, { say $0.Str.encode.decode } ); 15:51
bisectable6 patrickb, Will bisect the whole range automagically because no endpoints were provided, hang tight
patrickb, ¦6c (53 commits): «cde␤»
patrickb, Nothing to bisect!
Shaeto can't find info how to call parent method, in p5 i use $self->SUPER:: what about raku ? 19:55
lizmat nextsame callsame 19:57
or specifically: $foo.Bar::methodname
Shaeto thank you! 19:59
codesections and the relevant doc are at docs.raku.org/language/functions#Re-dispatching
s/doc/docs/
Shaeto i tried to read objects inheritance docs
codesections Are set operations _supposed_ to exclude falsy values? 20:19
m: say Map.new((:foo(0), :bar(''), baz(1))) (-) Map.new((:qux(2))) 20:20
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
baz used at line 1. Did you mean 'bag'?
codesections m: say Map.new((:foo(0), :bar(''), :baz(1))) (-) Map.new((:qux(2))) 20:21
camelia Set(baz)
codesections I found/find ^^^^ *very* surprising. Is it buggy, or am I just confused?
hmmm, the following seems inconsistent, which makes me think the above might be a bug 20:24
m: say ('', 0, 1) (-) (2) 20:25
camelia Set( 0 1)
raydiak it is documented: second paragraph and following example at docs.raku.org/type/Set#Creating_Set_objects 20:49
raydiak see also the table at the bottom of the introduction at docs.raku.org/language/setbagmix which I'd assume is the justification for such behavior 20:54
codesections raydiak: thanks. That's interesting, and might be worth noting in the (-) docs [I might do so, actually] 20:58
I don't really see how the table in setbagmix provides a justification, though? 20:59
from that table, I might expect Map.new((:foo(''), :bar)) (-) Map.new((:bar)) to return Set.new(:foo(0)), but I wouldn't expect the empty set 21:02
(Not arguing -- the other page you linked is clear that it's intentional. I'm just still confused)
raydiak so anything in a Set which :exists is True 21:03
codesections m: say Map.new((:foo(0)))<foo>:exists 21:05
camelia True
raydiak so when coercing the Map to a Set, it's calling .Bool on each value and doing what makes sense to a Set with that - throwing away the false things because they aren't in the set, according to set semantics
yes I agree it feels to me like we're confusing truthiness with existence to some extent
codesections m: say (0, '').Set 21:06
camelia Set( 0)
codesections m: say (0, False, 1).Set
camelia Set(0 1 False)
codesections m: say (0, False, 1, :p(0)).Set 21:07
camelia Set(0 1 False)
codesections ^^^ I think it is something to do specifically with the slightly odd smartmatching for Pair 21:08
(not unjustified -- it powers some cool features. But, still, it still seems a bit odd) 21:09
raydiak keys of any sort are allowed. it's the truthiness of the *value* that matters, which only exists when you're converting from a map-like thing or a pair or pairlist
look at how bag and mix work...if something drops to zero, it's not in the collection any more. so I guess someone thought "Sets should work just like that but under Bool instead of Int or Real" 21:10
codesections ohh, thanks, that's a helpful way of putting it 21:11
re: someone thinking that -- maybe. But I also think it falls naturally out of the Pair smartmatch symantics 21:12
tonyo this is the relevant code: github.com/rakudo/rakudo/blob/mast...h.pm6#L392 21:13
codesections agreed, that or maybe the method right below it SUB-PAIRS-FROM-SET, which notes that it uses Pair semantics 21:15
(aka, the semantics that mean :bar(42) ~~ :foo(42) returns True) 21:16
oddp This works: say slurp.chomp.comb.map(...); now, if i wanna break that chain up and insert a newline after slurp, the whole thing breaks. Why's is calling slurp and not considering the .chomp... on the next line? thought we had semicolons just for that? 22:40
gives: "No such method 'chomp' for invocant of type 'Any'" 22:41
oddp slurp() looks a bit ugly, but i guess i have to go with that for now 22:42
codesections oddp: it's actually not the newline specifically -- it's any whitespace (because foo.method and foo .method have different precedence). I'm pretty sure you can do `slurp\ .chomp`, though 22:47
m: say -1.abs; say -1 .abs; say -1\ .abs 22:48
camelia -1
1
-1
moon-child I think \ is even uglier than () :P 22:49
codesections :D fair.
oddp and why are both slurp().chomp and slurp() .chomp working then?
kybr m: class Foo { has $!sig = :($x = 1, $y = 1); method foo($!sig) {} } 22:50
camelia ===SORRY!===
QAST::Block with cuid 1 has not appeared
MasterDuke kybr: interpolating a signature bound to/stored in a variable as the signature for a sub/method is not (currently at least) possible 22:52
kybr MasterDuke: thanks. 22:54
maybe i'll generate some code then. 22:55
codesections oddp: I'm not 100% sure of the details, but it's caused by the fact that &infix:<.> (the one with a space) has lower precedence than the .method call, and that means that `slurp .chomp` is parsed as `slurp(Any.chomp)` -- which isn't possible with slurp() .chomp or slurp.chomp 22:57
MasterDuke github.com/rakudo/rakudo/issues/3786 and github.com/rakudo/rakudo/issues/1301 are related to the QAST::Block and cuid error 22:58
oddp `slurp(Any.chomp)` -- hm, interesting. alright, thanks for your input! 23:00