🦋 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.
tonyo m: say S:g/ $<a> = <:Lu> || $<b> = <:!Lu> /{$<a>??$/.lc!!$/.uc}/ given "AbCd" 00:09
camelia aBcD
tonyo there ya go 00:10
codesections :-) so much better
guifa Actually if yyou're doing that, there's no reason to check for <:!Lu>, you can just do $<b> = . 00:14
m: say S:g/ $<a> = <:Lu> || $<b> = . /{$<a>??$/.lc!!$/.uc}/ given "AbCd" 00:15
camelia aBcD
guifa m: say S:g/<:L>/{$/ eq $/.lc??$/.uc!!$/.lc}/ given "AbCd" 00:16
camelia aBcD
guifa Golfing further (at the cost of perf) 00:19
m: say S:g/./{$/eq$/.lc??$/.uc!!$/.lc}/ given "AbCd" 00:20
camelia aBcD
guifa points out that after codesections 's last reddit post, he's not allowed to complain about line noise in the last time 00:21
moon-child one char longer, infinitely classier:
m: say S:g/./{[&lc,&uc][$/eq$/.lc]($/)}/ given "AbCd" 00:22
camelia aBcD
guifa ^_^
codesections Agreed
guifa Also, I think I finished up Dateish.fmt … I think the formatters' code isn't too ugly 00:30
Thoughts? github.com/alabamenhu/DateTimeFmt/...imeFmt.pm6
SmokeMachine Does anyone know a fix for this? github.com/raku-community-modules/...t/issues/6 00:59
moon-child probably the api should be redesigned to take an array of lines for 'expected' and call .lines on the result of the function 01:02
codesections guifa: that looks like about the most readable nqp I've seen :D 01:40
rassoc noob question regarding that code: why bother with nqp::if when the regular if would be more readable? perf seems to be the same, according to this answer: stackoverflow.com/questions/551072...8#55107548 01:56
codesections Wait, I think I'm missing something, rassoc. What in that answer tells us that there's no perf difference? 02:08
rassoc wouldn't perf be listed under notable differences if it was significant? 02:10
codesections Hmm, I'm not sure. That seems like some evidence, but not 100%. In particular, I thought that some (all?) of the perf cost of an `if` came from building a new lexical scope, which is the second bullet 02:16
(the perf cost of it versus other conditionals, I mean – obviously branching code is going to lead to branch prediction misses/less optimized code in general, but that goes for any branching/condititioal) 02:17
rassoc well, what the heck do i know. all my raku stuff runs like arse, not yet qualified to contribute on that front ;) 02:25
codesections well, don't take my word for it, that's for sure! 02:26
moon-child I want to pass a Buf into a nativecall function. Is there a way to do that? 03:17
looks like nativecast(Pointer) will do it 03:18
moon-child m: use NativeCall; my Pointer $x; say nativecast(size_t, $x) 04:03
camelia (signal SEGV)
moon-child ^ is that right? Shouldn't it print 0? 04:03
tonyo what is your Buf of? 05:13
Buf[uint8] ?
moon-child yeah 05:14
tonyo you likely just want to pass uint8[] and the size 05:15
whatever func(unsigned int xs[], int xl) 05:16
or whatever your actual compiler type is func(uint8_t xs[] ..) 05:17
moon-child no, it's a string
Str on raku side, buffer (not nul-terminated) on c side
tonyo buffer of unsigned chars, then? 05:18
or wide chars?
moon-child regular size chars
nativecast(Pointer) seems to do the job 05:19
tonyo oh, those fools. you can cast pointer but you'll still want the length
unless it's always fixed
moon-child well, yeah, but that's easy
tonyo not if you can't count 05:20
guifa oof 05:49
I did something that's slowing down my dateish.fmt code. Suddenly got to be an order of magnitude slower =\
guifa But … I'm a good 50% faster than sprintf generating a similar string, so I guess it's not terrible then given I'm handling all the same padding features. 05:59
moon-child maybe you should submit a patch to improve sprintf's performance! 06:01
guifa moon-child: there's probably a little bit more going on under the hood with sprintf 06:07
but lizmat has been working on optimizing sprintf via caching the formatters, I don't think that's in the master branch just yet
guifa I'll do the same to my code once that's done and given that doing .&{ .year ~ '-' ~ .month ~ '-' .day } is currently about 30x faster than .fmt('%Y-%m%d') and about 60x faster than sprintf('%d-%d-%d', $date.year, $date.month, $date.day), I'd imagine the cached method will bear some pretty substantially improvements 06:10
s/once that's done/once RakuAST is done
gfldex Discord bridge test. 10:29
suman m:my $num = 20129201828;my @arr= 2018..2020;if $num ~~/@arr.any/ { say "Matches"} 14:37
evalable6
suman m:my $num = 2012920128282020;my @arr= 2018..2020;if $num ~~/2018|2019|2020/ { say "Matches"} 14:39
evalable6 Matches
suman m: my $num = 2012920128282020;my @arr= 2018..2020;if $num ~~/{2018..2020}/ { say "Matches"} 14:40
camelia Matches
suman m: my $num = 2012920128;if $num ~~/{2018..2020}/ { say "Matches"} 14:42
camelia Matches
suman Why is this code matching? Isn't it supposed to not match? 14:42
m: my $num = 2012920128;if $num ~~/{2018..2020}/ { say "Matches"}
camelia Matches
moritz you never told raku that you want to match a full string 14:53
so it searches for a substring
m: my $num = 20129201828; my @range = 2018...2020; say $/ if $num ~~ /^@range$/ 14:54
camelia ( no output )
moritz m: my $num = 20129201828; my @range = 2018...2020; say $/ if $num ~~ /^@range/
camelia ( no output )
moritz m: my $num = 2029201828; my @range = 2018...2020; say $/ if $num ~~ /^@range/
camelia ( no output )
moritz m: my $num = 2019201828; my @range = 2018...2020; say $/ if $num ~~ /^@range/
camelia 「2019」
moritz m: my $num = 2019201828; my @range = 2018...2020; say $/ if $num ~~ /^@range$/
camelia ( no output )
moritz but if you just want to check a number, no need to go for a regex
m: say 2019 ~~ 2018..2020 14:55
camelia True
moritz m: say 201933 ~~ 2018..2020
camelia False
suman m: my $num = 2019201828; my @range = 2018...2020; say $/ if $num ~~ /@range/; 15:03
camelia 「2019」
suman m: my $num = 2019201828; say $/ if $num ~~ /{2018...2020}/;
camelia 「」
suman Is it possible to keep raku expression within regex? 15:04
m: my $num = 2019201828; say $/ if $num ~~ /{2018...2020}/;
camelia 「」
suman in this example range within regex directly
moritz m: my $num = 2019201828; say $/ if $num ~~ /<{2018...2020}>/ 15:12
camelia 「2019」
moritz see docs.raku.org/language/regexes#Reg...erpolation 15:13
gfldex Discord bridge test. 15:31
RandalSchwartz seriously? I can get rid of adium and just use discord? 15:32
gfldex not quite yet
For now I only implemented IRC -> Discord. IRC <-> Discord needs more thinking.
Those Dicord Inc folk really like their rate limiting. :-/ 15:33
gfldex TIL sub EXPORT can be a multi 19:01
gfldex lolibloggedalittle: gfldex.wordpress.com/2021/06/23/be...agmat-ish/ 19:57
Geth doc: 2de140bc33 | Coke++ | 7 files
Remove unneeded 'use v6' from util/

Part of #3905
20:41
Geth doc: f8251bedf0 | Coke++ | 2 files
rename to .raku extension

Part of #3905
20:43
[Coke] "oh, a doc commit, c... oh, that was me." 20:51
gfldex you are very commited to the docs :)
Geth doc: coke self-assigned error when binding variables github.com/Raku/doc/issues/3908
a254a27d09 | Coke++ | 14 files

Update references to old file names
Closes #3905
23:48
Geth ¦ doc: coke self-unassigned error when binding variables github.com/Raku/doc/issues/3908 23:51