🦋 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 available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 8 June 2022.
MadcapJake m: class A { has $.name; has &.block; submethod BUILD(:$!name, :&!block) {} }; my %as = alpha => A.new :name<alpha> :block(->{}), beta => A.new :name<beta> :block(->{}); my Map $m := Map.new(%as.values>>.name Z %as.values>>.block); $m.WHAT.say; $m<alpha>.say; $m<alpha> = 'foo'; $m<alpha>.say; 02:55
Voldenet m: class A { has $.name; has &.block; submethod BUILD(:$!name, :&!block) {} }; my %as = alpha => A.new :name<alpha> :block(->{}), beta => A.new :name<beta> :block(->{}); my Map $m := Map.new(%as.values>>.name Z %as.values>>.block); $m.WHAT.say; $m<alpha>.say; $m<alpha> = 'foo'; $m<alpha>.say; 02:56
camelia (Map)
-> { #`(Block|4932231743384) ... }
foo
sienet_ja_LSD[m] why is it that JSON parse fails in every third run? 15:20
lizmat sienet_ja_LSD[m]: do you have a golf for that ? 15:21
sienet_ja_LSD[m] I run the script and it works fine like 2 out of 3 times, and then one in 3 it's Type check failed in binding to parameter '%case'; expected Associative but got Any (Any)
golf? 15:22
lizmat the smallest piece of code that shows the problem
sienet_ja_LSD[m] I can upload
lizmat please 15:24
sienet_ja_LSD[m] ix.io/40WL 15:26
^ 15:27
lizmat looks like the JSON is really at raw.githubusercontent.com/exercism...-data.json :-) 15:29
sienet_ja_LSD[m] yes that one but I downloaded it and renamed it bob.json
anyway it fails 15:30
it works but fails, unpredictably
lizmat yeah, confirmed it fails
feels like some race condition deep in the internals :-(
sienet_ja_LSD[m] hmm ok 15:31
lizmat could you make a Rakudo issue for that? 15:32
sienet_ja_LSD[m] yeah sure
lizmat thanks!
ah... I think I have a hunch it's not a system issue after all 15:35
sienet_ja_LSD[m] it's fixable? 15:36
lizmat well... where did you derive the [1] in .List[1] from ? 15:37
sienet_ja_LSD[m] I just wanted the second entry, there's only two. [0] is description and [1] an array of cases 15:38
lizmat ah, but the outer structure in the JSON is a hash, and the order of keys in a hash is indeterminate
sienet_ja_LSD[m] hmm figures 15:39
yeah true :D
by removing the list method it seems to work 15:40
thanks 15:41
lizmat as a one liner: 15:43
say .<description> for from-json("bob.json".IO.slurp)<cases>.list;
gfldex is there any way to protect a class from being exported? 18:33
Found one. Sadly, I already started with the blogpost and I have no idea how to explain what I'm doing. :) 18:40
gfldex lolibloggedalittle: gfldex.wordpress.com/2022/06/26/sinking-errors/ 19:16
uzl[m] m: say min [1, 2, 3], {1/$} 19:25
camelia -> ;; $_? is raw = OUTER::<$_> { #`(Block|2800384389576) ... }
uzl[m] m: say min [1, 2, 3], by => {1/$}
camelia Use of uninitialized value of type Any in numeric context
1
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in bl…
uzl[m] m: say min 1, 2, 3, by => {1/$} 19:27
camelia Use of uninitialized value of type Any in numeric context
1
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in bl…
uzl[m] m: say min(1,7,3,:by( { 1/$_ } ));
camelia 7
uzl[m] m: say (1, 7, 3).min({1/$_}) 19:28
camelia 7
uzl[m] I was just going to ask why the asymmetry between the function and method calls for `min` and `max` when passing a callable but I now realize it makes sense. If you passed the callable as a positional parameter in the function call, then it'd be considered just another value 😅 19:31
m: say min 1, 2, 3, by => {1/$}
camelia Use of uninitialized value of type Any in numeric context
1
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in bl…
uzl[m] m: say min 1, 2, 3, :by({1/$}) 19:32
camelia Use of uninitialized value of type Any in numeric context
1
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in bl…
uzl[m] m: say min(1, 2, 3, :by({1/$}))
camelia Use of uninitialized value of type Any in numeric context
1
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in bl…
uzl[m] m: say min 1, 2, 3, :by({1/$_}) 19:33
camelia 3
uzl[m] m: say min 1, 2, 3, by => {1/$_}
camelia 3
Geth modules.raku.org: zoffixznet++ created pull request #144:
s/perl6/raku/ in site tips
23:12
SmokeMachine I got it right? Is Zoffix back?! 23:14
uzl[m] It seems like it 👍️ 23:28
SmokeMachine \o/ 23:33