🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
00:28 lucasb left 00:34 dataangel left 00:41 tejr left, xelxebar left, asymptotically left 00:44 pecastro left 00:53 sftp left 00:54 sftp joined 00:55 ssm__ joined 01:00 guifa2 left, tejr joined 01:03 asymptotically joined, xelxebar joined 01:05 tejr left, JRaspass left 01:06 tejr joined 01:11 squashable6 left 01:12 gordonfish left 01:13 squashable6 joined 01:20 simcop2387 left 01:32 simcop2387 joined, simcop2387 left, simcop2387 joined, mowotter left 01:36 sftp left 01:37 guifa2 joined 01:38 JRaspass joined 01:41 MasterDuke left 01:47 gordonfish joined 01:55 gnufr33dom joined 02:11 guifa2_ joined, guifa2 left, guifa2_ is now known as guifa2 02:28 kvw_5 joined 02:32 kvw_5_ left 03:16 JRaspass left 03:18 sftp joined 04:18 evalable6 left, greppable6 left, benchable6 left, statisfiable6 left, unicodable6 left, bisectable6 left, linkable6 left, quotable6 left, shareable6 left, coverable6 left, notable6 left, committable6 left, bloatable6 left, squashable6 left, tellable6 left, nativecallable6 left, sourceable6 left, releasable6 left 04:19 bisectable6 joined, notable6 joined, nativecallable6 joined, tellable6 joined 04:20 statisfiable6 joined, bloatable6 joined, evalable6 joined, squashable6 joined, greppable6 joined, releasable6 joined, committable6 joined 04:21 benchable6 joined, squashable6 left, quotable6 joined, linkable6 joined, unicodable6 joined, coverable6 joined, shareable6 joined, sourceable6 joined 04:22 squashable6 joined 04:42 rindolf joined
kawaii I'm working on a basic !uptime command for a bot I'm writing, is there some more Perly way to do this instead of my clunky if/else? And possibly some hack to also switch between 'minute' and 'minutes' if $mins == 1 or not? :) www.irccloud.com/pastebin/H5G7rEEp/ 04:44
($start is defined way above at the... start... of my code) :) 04:47
05:00 raku-bridge left, raku-bridge joined 05:11 k-man left 05:13 k-man joined 05:19 brtastic joined
elcaro kawaii: it can be done, but I think it would less readable 05:20
regarding pluralising words... i usually avoid golfing something like "you have { $n } thing{ 's' if $n ≠ 1 }"
I would rather write "you have $n { $n == 1 ?? 'thing' !! 'things' }" 05:21
even tho it's more typing
kawaii elcaro: oh both of those are nice solutions, thanks!
elcaro butbut with that caveat out of the way
tio.run/##PY5bCoMwEEX/XcVFhCQlBPvy...beJqxNP0BQ
i think it's less readable that what you've got tho. could also use `when` instead of `if` so your blocks align more nicely 05:22
but it's your code... do what you want... and "clever" code is usually ok in little scripts 05:23
kawaii elcaro: your solution there is actually quite concise, and legible, thank you very much :) 05:25
elcaro i had to rename your vars so I could build pairs out of them and just use the .key in a loop 05:27
it's a nice little trick
the toggle ensures we only ignore subsequent leading zero's 05:28
so the case where you have > 0 hours and seconds - but 0 mins - is handled fine
although it doesn't join the final 2 values with "and". 05:31
05:32 kaiwulf left
sortiz m: sub dur(:$s=0,:$m,:$h) { ($h ?? "$h hours, " !! '') ~ ($m ?? "$m minutes and " !! '') ~ "$s seconds" } say dur(:1s); say dur(:2s,:3m); say dur(:2m,:3h); # A basic approach with the same original semantic (Don't show zeros) 05:37
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3$m minutes and " !! '') ~ "$s seconds" }7⏏5 say dur(:1s); say dur(:2s,:3m); say dur
expecting any of:
sortiz m: sub dur(:$s=0,:$m,:$h) { ($h ?? "$h hours, " !! '') ~ ($m ?? "$m minutes and " !! '') ~ "$s seconds" }; say dur(:1s); say dur(:2s,:3m); say dur(:2m,:3h); # A basic approach with the same original semantic (Don't show zeros) 05:38
camelia 1 seconds
3 minutes and 2 seconds
3 hours, 2 minutes and 0 seconds
kawaii elcaro: doing that is way more trouble than it's worth imho, here's an example of that with an array of terms, almost illegible; `@items.&{ .head(*-1).&{ .join(", ") if $_ }, .tail }.join: " and "`
m: my @items = 'apple', 'peach', 'watermelon', 'lemon', 'lime'; say @items.&{ .head(*-1).&{ .join(", ") if $_ }, .tail }.join: " and "; 05:40
camelia apple, peach, watermelon, lemon and lime
moon-child kawaii: no oxford comma ;-; 06:16
sortiz: instead of ($h ?? "$h hours, " !! '') you can use ("$h hours, " if $h) 06:17
06:18 japhb left
moon-child m: my @a = <apple peach watermelon lemon lime>; print "@a[0 .. *-2].map({"$_, "}).join()and @a[*-1]"; 06:20
camelia apple, peach, watermelon, lemon, and lime
sortiz moon-child++, you're right
moon-child oh, no, even easier 06:21
m: my @a = <apple peach watermelon lemon lime>; print "@a[0 .. *-2].join(', '), and @a[*-1]"
camelia apple, peach, watermelon, lemon, and lime
kawaii moon-child: it's 06:21, let's not have this debate now ;3
moon-child kawaii: why are you up so early?? 06:23
(though granted it's pretty late here...should sleep but eh)
kawaii I do my best work at night, I'll go to sleep shortly
sortiz Sweet dreams 06:25
06:32 wamba joined 06:38 ufobat__ joined 06:52 rindolf left
elcaro moon-child: your code fails with a list of 1 :D 06:53
moon-child elcaro: tbf you probably wanna special-case both 1 and 2 anyway 06:55
because for 3 items: a, b, and c. For 2 items: a and b
elcaro yeah, I'm fairly certain there's a Lingua::* module for perl that does it
oh wait... there's already a Raku port: Lingua::Conjunction 06:56
07:16 aluaces joined 07:22 sjm_uk joined 07:26 telex left 07:27 telex joined 07:28 defaultxr left 07:29 defaultxr joined 07:30 domidumont joined 07:31 parabolize left 07:33 patrickb joined 07:40 gnufr33dom left 07:46 gnufr33dom joined 07:49 jcarty joined 07:52 Xliff left
jcarty Hello, is there a way to add something like error reporting to rakus grammars? I have a kind of large grammar and finding errors in some of the things it tries to read is challenging 08:00
08:01 gnufr33dom left
andinus docs.raku.org/programs/01-debuggin...tribution) 08:04
docs link to Grammar::Debugger ^
08:06 Garbanzo left 08:08 krkini joined, kini left
kiti_nomad[m] Ask a very silly question, what does LWP mean 08:09
jcarty I've used Grammar::Debugger before in the past but that's more for actively debugging right? I was looking for a way to try and report something during it's regular use rather than just saying the parser failed. 08:10
moon-child kiti_nomad[m]: (l)ib(w)ww (p)erl?
moritz jcarty: something like Grammar::ErrorReporting? 08:11
shill warning: that's my module :-)
there's also Grammar::PrettyError
jcarty I think so I will take a look 08:12
moritz *and* Grammar::Message, because two modules aren't enough :D
also, my parsing book has a chapter on error reporting
kiti_nomad[m] right,thx 08:16
moon-child
jcarty moritz where would I find Grammar::Message. I found ErrorReporting and Pretty Error on Raku land. 08:19
andinus jcarty: it's in p6c ecosystem 08:21
github/ugexe/Perl6-ecosystems
moritz jcarty: modules.raku.org/search/?q=Grammar%3A%3AMessage 08:22
jcarty Ah thanks!
08:28 abraxxa joined 08:32 dotdotdot left 08:33 abraxxa left 08:34 abraxxa joined 08:50 Scimon joined 09:02 TheAthlete joined 09:07 pecastro joined 09:10 JRaspass joined 09:12 Sgeo__ left 09:14 CIAvash left 09:15 CIAvash joined, SmokeMachine joined 09:18 CIAvash left, matiaslina left 09:20 PimDaniel joined 09:21 MitarashiDango[m left, Tirifto[m] left, ThaEwat left, unclechu left, AlexDaniel` left, JJAtria[m] left 09:22 kiti_nomad[m] left 09:30 sortiz left 09:36 jmerelo joined
PimDaniel Coke: thank's for the subset you published for me yesterday after i leaved! 09:36
tellable6 2021-01-21T21:57:39Z #raku <[Coke]> pimdaniel gist.github.com/coke/53cf70ad3bc41...7b8e2b336f - there's a subset variant.
jmerelo releasable6: status
releasable6 jmerelo, Next release in ≈1 day and ≈9 hours. 1 blocker. 22 out of 74 commits logged
tellable6 2021-01-20T00:47:30Z #raku <tony-o> jmerelo another article/bit of info on zef eco - deathbyperl6.com/faq-zef-ecosystem/
releasable6 jmerelo, Details: gist.github.com/f8693ea70005474438...910241b81f
jmerelo .tell tony-o thanks!
tellable6 jmerelo, I'll pass your message to tony-o
PimDaniel I did not know the yet the subset keyword, so could not imagine it as a possibility. 09:37
tellable6: thank's i saw i in the #raku logs i whatch each morning. 09:42
tellable6 PimDaniel, I cannot recognize this command. See wiki for some examples: github.com/Raku/whateverable/wiki/Tellable
09:45 sena_kun joined 09:48 jcarty left, TheAthlete left 09:51 PimDaniel left 09:55 abraxxa left 10:06 ThaEwat joined 10:10 abraxxa joined 10:13 AlexDaniel` joined, unclechu joined, JJAtria[m] joined, CIAvash joined, matiaslina joined, kiti_nomad[m] joined, MitarashiDango[m joined, Tirifto[m] joined, MitarashiDango[4 joined 10:24 donaldh joined 10:49 wamba left 10:52 jcarty joined
jcarty moritz Pretty errors is just what I was looking for initially thanks 10:52
10:59 dotdotdot joined 11:38 natrys joined 11:41 jcarty left, wamba joined 11:43 ufobat_ joined 11:47 ufobat__ left 11:52 patrickb left 12:09 abraxxa left, PimDaniel joined
PimDaniel Hi \o 12:10
andinus hi o/
PimDaniel I see that defined/not defined works.
like in Perl5
but Is is the good way to check definition of a variable? Or should a boolean check with if suffice? if $var {...} ???? 12:12
moritz that depends on what you want to check
El_Che $var.defined is a winner
moritz if you have an Int variable, for example if $var { ... } will be false both for undefined and 0
PimDaniel re 'my Int $i=0; say $i.defined' ==> True 12:14
re 'my Int $i=Nil; say $i.defined' => False
moritz: defined to 0 IS defined. 12:15
12:16 a3r0 left, a3r0 joined
PimDaniel You meant : if i just check it with if. 12:17
elcaro yes, `if $x` just checks "truthiness", and Int 0 is "falsy", as is the empty list 12:18
m: my @a; say so @a;
camelia False
elcaro btw, `so` is the opposite of `not` 12:19
ie. a low precedence boolean coercer
PimDaniel re 'my Int $i=0; if $i {say "OK"} else {say "NO"}' ==> "NO"
Ok thank's , this is logical! 12:20
elcaro oh, there's also prefix `?` which is the opposite of prefix `!` 12:21
m: my @a; say ?@a; say !@a;
camelia False
True
12:28 patrickb joined 12:47 rindolf joined 13:11 ufobat__ joined
PimDaniel Just to remind : what is the remplacement for : (statement(true)) ? do something : do other thing; in Raku. 13:13
13:13 ufobat_ left
PimDaniel i mean : (expression)? do this : do that; 13:14
13:14 aborazmeh joined, aborazmeh left, aborazmeh joined
guifa2 Statement ?? ifTrue !! ifFalse 13:15
PimDaniel guifa2: YESS! thank's : docs.raku.org/routine/%3F%3F%20!!
may submethod BUILD come with custom new method? 13:25
and if YES : must signatures be different? 13:27
moritz the two are pretty orthogonal 13:28
new() tends to call bless()
and bless in turn calss submethod BUILD
youc an use whatever arguments you like for new
but BUILD receives named arguments for each attribute to be initialized
PimDaniel if i have a custom new with a special signature : when i call it with my special caller : ok 13:31
I have a submethod BUILD with another signature and when i try to call it with another new caller : it complains that new sub has not good parameters. 13:33
what dit i not understand?
moritz show us the code (ideally condensed to the essential part) 13:34
PimDaniel pastebin.com/RgJhgRAB 13:35
13:36 aborazmeh left
PimDaniel note that method new alone works and method BUILD alone works too with good callers. 13:36
may be shoud i make a multi new instead... 13:38
caller for new instance : my $l = Line.new((33,22),(100,22), int-motif => 8364)
caller for BUILD which should be the default caller : my $l = Line.new(a => Point.new(33,22),b => Point.new(100,22),motif => 'X'); 13:39
13:40 aborazmeh joined, aborazmeh left, aborazmeh joined 13:43 Black_Ribbon left
PimDaniel I'v found the error : in this case, new MUST be a multi method. 13:48
... which seams logical since BUILD is a constructor too. 13:49
moritz it must only be a multi if you want the default to work (with named arguments) 13:50
13:51 JRaspass left
PimDaniel Ok thank's moritz! 13:52
14:02 aborazmeh left 14:05 sena_kun left, sena_kun joined 14:06 PimDaniel left 14:26 TheAthlete joined, mowotter joined 14:39 gnufr33dom joined 14:50 mowotter left 15:03 JRaspass joined 15:13 Sgeo joined 15:17 lucasb joined 15:23 wamba left 15:24 wamba joined 15:27 aborazmeh joined, aborazmeh left, aborazmeh joined 15:33 b2gills left 15:44 parabolize joined 16:00 MitarashiDango[m left 16:03 JRaspass left 16:10 aborazmeh left
[Coke] yawns. 16:12
16:13 b2gills joined
lucasb that is contagious 16:35
[Coke] muahaha 16:37
16:38 mowotter joined 16:40 gnufr33dom left 16:59 Scimon left
guifa2 Yeah in COVID times that's dangerous 17:00
17:03 sortiz joined, TheAthlete left 17:05 JRaspass joined 17:22 JRaspass left 17:30 shiva joined 17:32 shiva left 17:36 APic joined 17:51 domidumont left 18:02 JRaspass joined, ufobat__ left 18:21 gdonald left
tony-o patrickb: updating the faq now, ty 18:40
tellable6 2021-01-22T09:36:53Z #raku <jmerelo> tony-o thanks!
patrickb o/
19:01 wamba left 19:06 MasterDuke joined 19:11 JRaspass left 19:18 wamba joined 19:29 JRaspass joined 19:58 jmchael joined 19:59 jmchael left, jmerelo left 20:06 asymptotically left, asymptotically joined 20:09 sortiz left 20:10 asymptotically left 20:11 asymptotically joined 20:21 summerisle joined 20:22 summerisle left 20:23 summerisle joined 20:24 summerisle left 20:25 summerisle joined 20:27 sjm_uk left 20:43 squashable6 left, squashable6 joined 20:47 wamba left 20:53 stoned75 joined 21:01 MasterDuke left 21:05 wamba joined 21:09 natrys left 21:17 rindolf left 21:20 aborazmeh joined, aborazmeh left, aborazmeh joined 21:27 cog_ joined 21:28 cog left 21:37 patrickb left
tbrowder \o 21:38
21:40 kaiwulf joined
tbrowder revisiting my prob yesterday with wrapping another sub (with help from dakkar, elcaro, and moritz), i think i may be able to use a Capture, if i read the docs correctly. 21:42
the wrapping sub: "sub foo($a, |c) { # rearrange the capture contents as necessary; my @res = wrapped-sub($a, c.Capture)}" 21:47
no, maybe: "my $c = c.Capture; @res = wrapped-sub($a, |$c);" 21:52
21:55 brtastic left
guifa2 Actually, c itself is a capture 22:05
So you only need @res = wrapped-sub($a, |c); 22:06
22:14 stoned75 left 22:16 bdju left 22:17 bdju joined 22:21 aborazmeh left 22:29 stoned75 joined
Tirifto[m] p6: map({ say $; $ }, map({ say $; $ }, (1, 2, 3))); 22:35
camelia 5===SORRY!5=== Error while compiling <tmp>
Name must begin with alphabetic character
at <tmp>:1
------> 3map({ say $7⏏5; $ }, map({ say $; $ }, (1, 2, 3)))
expecting any of:
infix
infix stopper
p…
tbrowder yes, but i need to modify it, so i took the hash "my %a = c.Hash;" modified the hash, and turned it into a new capture "my $d = %a.Capture" and fed it to my wrapped sub "my @res = wrapped $a, :$b, |$d" 22:36
Tirifto[m] (My apologies; I didn’t realise my client would mess with the text.)
22:38 Tirifto joined
tbrowder i have a simple test prog that works. now i have to try it in the real mccoy! 22:38
guifa2 tbrowder: ah, okay. If you are just using the hash values from the capture, then you can skip a step and just slip in the hash, e.g. wrapped $a, |%a 22:41
tbrowder ok, cool, thnx
Tirifto[m] p6: map({ say $_; $_ }, map({ say $_; $_ }, (1, 2, 3))); 22:53
camelia 1
1
2
2
3
3
Tirifto[m] ^ Just wanted to say I found this pretty curious. 😸
22:53 stoned75 left 22:55 autark joined
Tirifto[m] I wonder how the order was determined here? Does the inner function only get mapped to an element when the outer function asks for an element first? 22:56
22:57 Black_Ribbon joined
guifa2 AFAIK map isn't lazy, but the order holds up when doing it a different way: 23:05
sub slow($x) { sleep 1; $x }; (1,2,3).map({ .say; slow $_ }).map( *.say );
evalable6 1
1
2
2
3
3
guifa2 And is different from 23:07
m: sub slow($x) { sleep 1; $x }; (1,2,3)>>.&{ .say; slow $_ }>>.&{ .say }; 23:08
camelia 1
2
3
1
2
3
23:09 aluaces left
guifa2 Tirifto: actually, the docs state that .map on a List *is* lazy 23:10
Tirifto[m] guifa2: Ohhh, okay, I see that part now. 23:11
It says ‘lazily’, so I didn’t see it when I lazily searched for ‘lazy’. :-)
guifa2 Tirifto: same actually :-) 23:12
(and hey, I just learned one of the small differences between .map and >>. )
Tirifto[m] I only remember that ». doesn’t provide a reliable order of function application. So technically it could also print «3␤1␤2␤1␤2␤3␤», right? 23:14
guifa2 Yeah. Although presently it does always execute in order 23:15
23:22 autark left
Tirifto[m] Hmm… so is that likely the reason the order goes like that, guifa2? Because ». is not lazy like map is when it comes to Lists? 23:23
23:25 sena_kun left
guifa2 Tirifto: Yeah, I believe so. Note the difference too: 23:26
say (1,2,3).map({$_}).WHAT; say (1,2,3)>>.&{$_}.WHAT
evalable6 (Seq)
(List)
guifa2 also excuse me while I rinse my keyboard off after that line noise mess
Tirifto[m] Have a good rinse! 23:27
23:28 wamba left
Tirifto[m] And I see… My understanding is that sequences are inherently more lazy, so that would fit in. :-) 23:29
Well, back to imperative style! I guess that was the right choice in the first place, given my care for side effects. 23:31
guifa2 m: sub slow($x) { sleep 1; $x }; (1,2,3).map({ .say; slow $_ }).eager.map( *.say ); 23:34
camelia 1
2
3
1
2
3
guifa2 Tirifto: ^^ if you want to use the functional style still 23:35
Tirifto[m] Ohh, eager! 23:41
guifa2: Thanks! I’ll see where it would fit in. Might end up with a hybrid approach. That feels like a good way to go with Raku in general. 23:44
23:52 Tirifto left