🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
00:03 reportable6 left, reportable6 joined 00:04 yewscion joined 00:19 leah2 left
jdv if someone is doing something funky with their .raku then its likely on them 00:24
that's what .gist is for iirc
the 2 have distinct purposes, right?
00:27 linkable6 left 00:28 linkable6 joined 00:36 Doc_Holliwould left
guifa jdv: .gist = human readable, .raku = recreate raku object, .put = computer readable 00:37
err 00:38
.gist = human readable (used by say), .raku = recreate raku object, .Str = computer readable (used by put and print)
codesections But in many cases, the .raku doesn't recreate the raku object, and there's no real path getting it to (other than implementing it manually) 01:11
m: | ~''
camelia ( no output )
codesections m: my class Foo { has $!bar; submethod BUILD(:$!bar) {}}; say Foo.new(:bar<baz>) eqv Foo.new(:bar<qux>)
camelia True
01:35 yewscion left
guifa codesections: I think that goes back to the private attributes being like implementatino details 01:47
02:12 greaser|q left, greaser|q joined 02:13 greaser|q is now known as GreaseMonkey 03:13 linkable6 left, evalable6 left 03:15 evalable6 joined 03:16 linkable6 joined
avuserow if I have a hash with an key that is either a list or not present in the hash, is there an easy way to iterate over it with a for loop? for example: 03:19
m: my %a = :a[1, 2, 3]; .say for %a<a>; .say for %a<b> # wrong
camelia [1 2 3]
(Any)
avuserow m: my %a = :a[1, 2, 3]; .say for @(%a<a> // []); .say for @(%a<b> // []) # best I've found so far
camelia 1
2
3
avuserow fwiw, in python I would write `for x in a.get("a", []): print(x)` 03:22
raydiak not sure if this is better for your use case, but you could also do: 03:31
m: my %a is default([]) = :a[1, 2, 3]; .say for |%a<a>; .say for |%a<b>
camelia 1
2
3
avuserow oh nice, I was wondering if we had a defaultdict equivalent somewhere 03:35
that definitely helps some of the time 03:36
usually when this frustrates me, I'm delving into data that came from json, so that's not an option unfortunately
raydiak ah, I could see that 03:37
avuserow m: my %a = :a[1, 2, 3]; .say for %a<a> andthen .list; .say for %a<b> andthen .list # also works, not sure if it's an improvement 03:49
camelia 1
2
3
raydiak oh, here's a neat trick I hadn't thought of before now... 03:52
m: my %a = :a[1, 2, 3]; .say for %a<a>:v; .say for %a<b>:v
camelia 1
2
3
04:00 ^[ left
avuserow raydiak++ nice 04:06
05:00 evalable6 left, linkable6 left 05:01 evalable6 joined 05:03 linkable6 joined 05:33 colomon left 05:36 colomon joined 05:59 emperor_time joined 06:02 reportable6 left 06:04 emperor_time left 06:05 reportable6 joined 06:25 xinming left 06:33 Doc_Holliwould joined 06:35 guifa left 07:19 Doc_Holliwould left 07:20 Doc_Holliwould joined 07:21 japhb left, Doc_Holliwould left 07:41 Sgeo left 08:41 reportable6 left, squashable6 left, linkable6 left, greppable6 left, coverable6 left, unicodable6 left, statisfiable6 left, quotable6 left, evalable6 left, bloatable6 left, shareable6 left, bisectable6 left, notable6 left, releasable6 left, benchable6 left, nativecallable6 left, tellable6 left, committable6 left, sourceable6 left, evalable6 joined, unicodable6 joined, releasable6 joined 08:42 linkable6 joined, nativecallable6 joined, notable6 joined, squashable6 joined, statisfiable6 joined, sourceable6 joined, greppable6 joined 08:43 committable6 joined, coverable6 joined, tellable6 joined, quotable6 joined, benchable6 joined, reportable6 joined, bloatable6 joined, bisectable6 joined, shareable6 joined 09:14 RandalSchwartz left 09:33 leah2 joined 09:44 Kaiepi left 09:48 Kaiepi joined 09:57 sena_kun joined 10:42 sono left 11:42 linkable6 left, evalable6 left, linkable6 joined 11:43 evalable6 joined 12:02 reportable6 left 12:05 reportable6 joined 12:45 yewscion joined 13:07 Guest92 joined 13:09 Altai-man joined 13:16 b2gills left 13:18 yewscion left, sena_kun left, leah2 left 13:25 leah2 joined 13:31 b2gills joined 13:37 Guest92 left 14:37 evalable6 left, linkable6 left 14:40 evalable6 joined, linkable6 joined 14:43 guifa joined 14:45 RandalSchwartz joined 15:23 guifa left 15:29 corwin left 16:13 jess left, guifa joined 16:22 kylese joined 16:42 corwin joined 17:01 guifa left 17:07 guifa joined 17:11 Sgeo joined 17:17 MrFantastik joined
MrFantastik junctions are cool 17:18
17:25 xinming joined
guifa my $junctions = 'cool' & 'awesome' & 'fun'; 17:39
17:45 MrFantastik left 17:53 jmask joined 18:02 reportable6 left 18:04 reportable6 joined 18:47 jmask left 18:52 swaggboi joined 18:58 swaggboi left 19:57 abraxxa-home joined
codesections .tell avuserow the most direct Raku translation of `for x in a.get("a", []): print(x)` is probably `for %a.keys { say %a{$_}}` 20:21
tellable6 codesections, I'll pass your message to avuserow
20:48 squashable6 left 20:49 xinming left 20:50 squashable6 joined
dcx Hey is there any way to stop interactive raku from closing when I press ^C? 21:02
Like in many languages that just stops the main thread and gets you a new line but here it causes the raku interpreter to close 21:03
In python I think it raises a keyboard exception I think
21:04 dolmen joined
MasterDuke34 i suspect the repl could start with a signal handler for ^C. probably worth raising an issue on github asking about it 21:07
leont control-C raises a SIGINT
You can handle that, but making it throw an exception right there and then is trickier 21:08
dcx Ok I'll open an issue :) 21:09
This is an issue for rakudo right?
kybr i'm trying to get the behaviour of the command line `sort -df` from our .sort operation. it is sortof .sort({$^a.uc cmp $^b.uc}) but that does not ignore all chars except letters and spaces. 21:10
codesections leont: what's tricky about throwing there? I would have thought that `signal(SIGINT).tap({die})` would work -- am I missing something? 21:11
kybr i guess i have to regex
21:11 yewscion joined
leont When will that throw? And whereto? 21:12
It's handled by the event loop, I can only assume it will be handled as other asynchronous IO 21:13
21:21 xinming joined
dcx Opened 21:22
21:36 kylese left
codesections m: <Nab Not word!z word@a other next>.sort: {S/\W//.&fc} 21:36
camelia ( no output )
codesections m: say <Nab Not word!z word@a other next>.sort: {S/\W//.&fc}
camelia (Nab next Not other word@a word!z)
codesections kybr: I'd probably do ^^^ (not sure if you'd count that as using a regex or not) 21:37
21:41 hankache joined 21:46 dolmen left 22:02 hankache left 22:12 abraxxa-home left 22:30 RandalSchwartz left 22:41 yewscion left 22:42 yewscion joined 23:09 monkey_ joined 23:21 GreaseMonkey left 23:22 greaser|q joined 23:23 greaser|q left, greaser|q joined, greaser|q is now known as GreaseMonkey 23:26 yewscion left 23:27 yewscion joined 23:31 yewscion left 23:54 monkey_ left