🦋 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.
valley Oh, ouch. Sometimes I feel like an idiot. I just assumed the `.raku` was there for a reason and didn't even think about removing it. Thank you for the help. I swear I'm not usually this dumb, programming after a long and stressful day of work can be hard. 00:01
moon-child :) 00:02
valley And I do plan on making this a pure Raku program if possible (meaning no capturing command/shell output). Whenever I get started with a new language, I make an info fetch program that initially captures command output, and I slowly work my way up to properly parsing files and all that. 00:05
00:12 Doc_Holliwould left 00:14 pecastro left, Doc_Holliwould joined 00:18 m_athias left, ape666 joined 00:21 m_athias joined 00:32 BenGoldberg joined 00:36 RaycatWhoDat left 00:39 jmchael left
codesections I just came up with an advent 00:45
*advent of code solution that is probably too short/cryptic to be anything I'd actually use, but it was a lot of fun to write: 00:46
(and, the more I look at it, the closer I come to convincing myself it makes perfect sense) 00:48
00:48 ben_ left 01:05 BenGoldberg left, BenGoldberg joined 01:06 RaycatWhoDat joined 01:12 ape666 left, RaycatWhoDat left 01:23 valley left 01:24 MasterDuke left 01:30 Util left, Doc_Holliwould left 01:33 lucasb left
MitarashiDango[m Couldn't you ditch the $p2 default and just use ?$p2 after the plus (for the sake of golfing further) 01:38
01:52 ape666 joined 01:56 aborazmeh joined, aborazmeh left, aborazmeh joined 01:58 fridim left, fridim joined 02:04 RaycatWhoDat joined 02:08 El_Che left, El_Che joined 02:11 RaycatWhoDat left 02:22 coldpress joined 02:35 ape666 left
codesections Yeah, I guess I could. I was kind of treating the `unit sub MAIN` line as "free" and just focusing on the "substantive" line 02:45
if I'm golfing the character count, I guess I'd want to use braces instead of `unit` too 02:46
guifa Weird. binding is slower than normal assignment
but not consistently? Maybe I Need better tests 02:48
03:02 RaycatWhoDat joined 03:06 RaycatWhoDat left, RaycatWhoDat joined 03:11 RaycatWhoDat left 03:28 sten37 joined
sten37 How to explain?? (1..5) »*« (6..10) (# no questions), but (1..5) [»*«] (6..10) (#same thing !) 03:31
(raku 2020.11) 03:32
03:37 leont left 03:43 ensamvarg3 joined
coldpress I can say lines.combinations(3); but why can't I my @combined-lines = lines.combinations(3); say @combined-lines; ? 03:52
I get this error: uv__close: Assertion `fd > STDERR_FILENO' failed.
invoking with `raku file < in`
.combinations(2) does not give this error
04:05 RaycatWhoDat joined 04:11 aborazmeh left, RaycatWhoDat left 04:12 dataangel joined, RaycatWhoDat joined 04:21 RaycatWhoDat left
coldpress it's all good now, plagarized raku AoC solutions :) 04:27
I think I don't understand how functions return values 04:28
`sub f() { ...; say ... }` outputs my answer, but `say f()` outputs Nil 04:30
04:30 Doc_Holliwould joined
moon-child coldpress: 'sub f() { foo; bar; baz }' returns baz 04:31
'say' returns null
coldpress correction: `sub f() { ...; say computation }` outputs my computation, but `sub f() { ...; computation } say f()` outputs Nil
moon-child m: sub f() { 5; 6; 7 }; say f() 04:32
camelia WARNINGS for <tmp>:
Useless use of constant integer 5 in sink context (line 1)
Useless use of constant integer 6 in sink context (line 1)
moon-child (also note that you can leave out the ()) 04:33
coldpress yes, that's what I expect. I think the when-for computation messes it up somehow? 04:34
moon-child code?
coldpress m: sub solve($lines, $p2) {[*] $_ if .sum == 2020 for $lines.combinations($p2 ?? 3 !! 2) }; say solve([1721,979,366,299,675,1456], True);
camelia Nil
coldpress m: sub solve($lines, $p2) {say [*] $_ if .sum == 2020 for $lines.combinations($p2 ?? 3 !! 2) }; solve([1721,979,366,299,675,1456], True); 04:35
camelia 241861950
04:37 squashable6 left
moon-child I'm not entirely sure why that's the case, but I do notice that wrapping parens around the expression in the function makes the problem go away 04:37
04:38 squashable6 joined
coldpress moon-child: by wrapping parens, you mean `sub solve { ( ... ) }`? This constructs a list, right? 04:42
that resolves my issue, thank you very much 04:43
04:46 xelxebar left, xelxebar joined
coldpress another way to resolve is `sub solve { return ... }` 04:48
no list is constructed, so I think this is preferable
04:57 RaycatWhoDat joined 05:02 RaycatWhoDat left 05:06 RaycatWhoDat joined 05:12 RaycatWhoDat left, RaycatWhoDat joined 05:19 RaycatWhoDat left 05:21 BenGoldberg left 05:41 Doc_Holliwould left 05:48 parabolize left 05:53 sten37 left 06:01 RaycatWhoDat joined 06:05 xinming joined 06:06 RaycatWhoDat left, RaycatWhoDat joined, sena_kun joined 06:08 xinming_ left 06:11 RaycatWhoDat left 06:43 aluaces joined 06:45 jmerelo joined
jmerelo Today's post starts with "Perl is dead" raku-advent.blog/2020/12/02/day-1-...-and-raku/ 06:46
sjn nice article :) 06:48
(though, I'd have loved to see some acknowledgment that Larry _and his community_ designed the language - many people had a hand in that process! Maybe there's an ackowledgment list somewhere to link to?) 06:50
Damian's work should definitely not go ignored, certainly. 06:52
Looking at design.raku.org/ there's an AUTHORS section at the end of most files 06:53
jmerelo: Maybe github.com/Raku/mu/blob/master/AUTHORS is a good list to link to? :) 06:54
06:56 domidumont joined 06:57 RaycatWhoDat joined 07:03 RaycatWhoDat left
jmerelo sjn: you can comment at the post, and the author is usually around here too 07:04
.seen nigehamilton
tellable6 jmerelo, I haven't seen nigehamilton around
jmerelo .seen nigehamilton_
tellable6 jmerelo, I haven't seen nigehamilton_ around
jmerelo .seen nige123
tellable6 jmerelo, I haven't seen nige123 around, did you mean nige1?
sjn no worries :) 07:05
07:07 RaycatWhoDat joined 07:11 RaycatWhoDat left 07:15 sjm_uk joined 07:23 aluaces left
coldpress hmm, URL says day-1 07:25
07:39 RaycatWhoDat joined 07:42 wamba joined 07:44 jmerelo left, RaycatWhoDat left 07:57 abraxxa joined 07:59 abraxxa left 08:00 abraxxa joined, jmerelo joined 08:01 RaycatWhoDat joined 08:02 fridim left 08:03 fridim joined 08:05 abraxxa left, abraxxa joined 08:06 RaycatWhoDat left, RaycatWhoDat joined 08:11 RaycatWhoDat left, RaycatWhoDat joined 08:12 BenGoldberg joined, frost-lab joined 08:15 aluaces joined 08:18 RaycatWhoDat left 08:25 skids left 08:39 dakkar joined 08:44 MasterDuke joined 08:45 BenGoldberg left 08:46 stoned75 joined
jmerelo coldpress: noted 08:57
coldpress: problem is I can't change it now... it was scheduled to be published yesterday initially. But I'll fix it for the next ones. Thanks! 08:58
09:02 nige joined
nige hi o/ 09:03
09:03 pecastro joined
nige happy to make an amend to the article - it's true that Larry designed it with the help of the community 09:04
github.com/Raku/mu/blob/master/AUTHORS <--- should I link to this one?
09:06 Altai-man joined, nige left 09:07 nige joined, Geth left
jmerelo nige: probably 09:08
09:09 sena_kun left, Sgeo left
nige ok - cool - sentence now reads: When Larry Wall designed Raku, with the help of the Perl community, he fixed most of Perl's imperfections and doubled down on Perl's DNA. 09:09
where "Perl community" links to - github.com/Raku/mu/blob/master/AUTHORS 09:10
and "designed" links to - design.raku.org
09:10 cpan-raku left 09:12 nige left, nige joined 09:16 nige left 09:17 nige joined 09:22 nige left, nige joined
JJAtria[m] Is there a reason we don't have a touch in IO::Path? I was expecting to see that, or have eg. modified be a setter as, but the closest I've seen is trizen.gitbook.io/perl6-rosettacod...ation_time 09:26
09:27 nige left, nige joined
jmerelo nige: please note this too raku-advent.blog/2020/12/02/day-1-...omment-368 09:36
09:41 ufobat_ left
notandinus what is the equivalent to perldoc for raku? 09:45
09:46 a3f left 09:49 harrison joined, aborazmeh joined, aborazmeh left, aborazmeh joined
moritz docs.raku.org/ 09:49
09:50 cpan-raku joined, cpan-raku left, cpan-raku joined
moritz there is some bare-bones command line tool, but IMHO it's not good enough to be worth using 09:50
notandinus which version of rakudo includes zef? looks like the one in openbsd ports doesn't come with zef 09:52
09:53 natrys joined
moritz zef is a third-party module 09:55
if you have access to a rakudo-star package, that should come with zef
notandinus i see, ports only has rakudo-2018.11 09:56
hmm looks like i can build the rakudo-star version from source, it has instructions for obsd 09:57
09:57 aborazmeh left
moritz also, rakudo development still moves quickly enough that I wouldn't advise using a 2 year old version 09:59
jmerelo even more so if it's prior to the rename...
notandinus i see, looks like someone did it sometime ago, blog.lambda.cx/posts/openbsd-compi...kudo-star/ 10:08
should i go the rstar way or get rakubrew from cpan and install with it?
Zero_Dogg You don't actually need rakudo-star these days. rakudo and zef should be enough 10:11
jmerelo notandinus: the rakudo star version has everything in and is reasonably up to date. Give it a try first. 10:12
notandinus i see, i'll try installing rakudo-star then 10:20
10:32 nige left, nige joined 10:37 nige left, nige joined 10:45 Doc_Holliwould joined 10:46 Black_Ribbon left 10:55 morayj joined
xinming Hi, today, I watched video from jnthn on youtube about perl6 optimization, we got quite a lot improvements there. but still got me curious, do we still have much room to optimize the compiler to make it run much faster than it was now? 10:57
10:57 nige left, nige joined
moritz xinming: there is some more potential, but it requires a few bigger changes, like the higher-level AST that preserves more context for the optimizer (rakuast branch) 11:01
11:01 nige left 11:02 nige joined
xinming moritz: Ok, Thanks, BTW, when I run raku script I wrote, I got, Command terminated, How can I debug this? 11:02
timotimo are you on linux? 11:04
xinming yea, I do
And I think it might be caused by
timotimo command terminates sounds like maybe a segfault or other signal
dmesg would usually point out segfaults 11:05
xinming class AA { multi method test ('aaa', My::ObjectType $object) { } }; AA.test('aaa', $obj);
timotimo: Ok
timotimo with rakudo-gdb-m you can get backtraces of where it asplodes
xinming Yea
I got it.
timotimo could be out-of-memory killed
there doesn't seem to be a $obj declared in your code 11:06
xinming Nope
timotimo: It's just illustration, It's a large script.
timotimo OK
xinming and later, I changed to AA.new.test('aaa', $obj) I got an error
timotimo infinite recursion is a way to get a crash at record speeds, though if you don't have a ulimit set it may make your computer unusable for a couple minutes 11:08
11:08 squashable6 left
xinming timotimo: yea, But my computer is not freezed at all, It just runs and runs, and soon, I receive Command terminated error. 11:09
timotimo OK
11:11 squashable6 joined
timotimo what kind of help would you like? 11:13
xinming Nothing ATM, Just now, I tried to repeat the issue, now, it always raises error. 11:14
11:14 rindolf joined
timotimo are you accessing one hash or array from multiple threads at the same time, per chance? 11:16
apart from NativeCall, that is one major way to segfault or crash a rakudo
xinming I don't think so, as I don't use multi threads feature 11:17
timotimo OK 11:18
xinming before I try to fix the issue, I don't know where I modified, it's now always raises error instead of `Command terminated` thin
timotimo oh, error as in an Exception 11:19
11:24 a3f joined 11:27 nige left, nige joined 11:29 Geth joined 11:31 nige left 11:32 nige joined 11:36 BenGoldberg joined
Geth advent: 58eadd37b8 | (Tom Browder)++ (committed using GitHub Web editor) | CONTRIBUTING.md

Update a bit. Needs more love.
notandinus ok so i installed rakudo-star from source on OpenBSD, it took ~1H with default module list 12:05
jmerelo notandinus++ 12:09
notandinus hmm something went wrong 12:10
ld.so: raku: can't load library 'libmoar.so'
^ it says this when i run it
12:11 BenGoldberg left 12:12 nige left, nige joined 12:14 abraxxa left 12:17 nige left, nige joined
notandinus hmm i figured out the error, i moved the whole directory to another location thinking that won't change anything. i've symlinked the old install directory to the new one & it works fine now 12:18
12:19 abraxxa joined
timotimo is that that one feature in rpath that openbsd doesn't have that we rely on for relocatable builds? 12:19
12:37 nige left, nige joined
Geth advent: b28fa1e3b3 | (Tom Browder)++ (committed using GitHub Web editor) | raku-advent-2020/authors.md
Update with new title
12:45 morayj left
notandinus what would be the best way to get each line of a file in an array? i'm thinking of slurp'ng it and splitting 12:46
lizmat my @array = "file".IO.lines
this will also remove newlines for you 12:47
if you want to keep them:
my @array = "file".IO.lines(:!chomp)
notandinus ^^ 12:48
notandinus ah thanks 12:49
i wanted this, found it from someone elses code : my @inputs = "input.txt".IO.lines>>.Int; 12:50
i need to read up on this methods thing, i only understand functions
lizmat if you just want to take from STDIN, its just "lines"
my @array = lines
if you want words from STDIN: 12:51
my @array = words
12:51 nige left 12:52 nige joined
notandinus ah thats nice, thanks 12:52
lizmat ah, and if you just want STDIN as a string: slurp
my $stdin-as-a-single-string = slurp 12:53
gfldex lolibloggedalittle: gfldex.wordpress.com/2020/12/02/sa...packaging/ 12:56
notandinus thanks, i'm saving these for later
i was doing the advent of code thing
13:01 domidumont1 joined 13:03 domidumont left 13:07 nige left, nige joined, sena_kun joined 13:09 Altai-man left 13:11 nige left 13:12 nige joined
Geth advent: 3b40509262 | p6steve++ (committed using GitHub Web editor) | raku-advent-2020/local-drafts/p6steve-rudolph-on-raku.md
some comments in the Bearing code section
notandinus how would i improve this: ix.io/2Gft 13:15
looks like $num scope is larger than the while loop, i want its scope to be only the loop 13:16
timotimo internal server error :< 13:17
notandinus oh, sorry looks like it got fixed, works fine on my end 13:18
timotimo m: my @nums = 1e0 ... 10e0; while shift @nums -> $num { say $num } 13:19
camelia 1
timotimo m: my @nums = 1e0 ... 10e0; while shift @nums -> $num { say $num }; say $num
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$num' is not declared. Did you mean any of these: 'num',
at <tmp>:1
------> 3e shift @nums -> $num { say $num }; say 7⏏5$num
timotimo ^- note that this will abort if the value shifted off the array booleans to false, for example 0e0
moritz notandinus: you could do something like: for @inputs.kv -> $idx, $num { }
and then only iterate over @inputs[$idx..*] inside the loop 13:20
timotimo @inputs.skip($idx) or $idx - 1 depending on what exactly you need
or + 1 i mean
notandinus ah that looks better, i only need to go over an index one time 13:21
so i'll iterate over @inputs[$idx..*]
13:22 nige left, nige joined
notandinus looks like that is significantly slower than previous code 13:25
i did: ix.io/2Gfx
this new one takes ~ 2.3 s whereas previous one took ~1.7 s 13:26
moritz internal server again :-(
notandinus what could be causing this?
moritz maybe that slice is slow
notandinus oh i guess ix.io is under load, i'll use another paste
13:26 nige left 13:27 nige joined
notandinus did it load? paste.debian.net is also down :( 13:27
moritz it loaded on the third attempt :D 13:29
notandinus oh ghostbin is also down, do you know of any other paste serivce?
ah nice
yeah the slice part is the only change, rest is same 13:30
moritz gist.github.com
perlpunks.de/paste 13:31
notandinus thanks i'll bookmark it 13:32
13:32 nige left, nige joined
notandinus raku in general seems slower than perl, will this improve in later versions? 13:35
moritz we're working on it
timotimo we just had a relatively big performance regression in the last release 13:40
which was a fix for correctness that wasn't fully optimized at the time of the release 13:41
sena_kun timotimo, I think it is relatively big in some isolated examples, though, not in general. 13:44
timotimo OK 13:49
13:51 nige left 13:52 nige joined 13:54 ggoebel joined 13:56 aindilis` joined 13:57 aindilis left
ggoebel how does one force an object to interpolate as a string in a regular expression? i.e. assume $a is an object where ~$a stringifies it to 'abc'. what is the correct way to say 'abc' ~~ /~$a/? 13:57
timotimo $a won't do it already? 13:58
ggoebel maybe I'm overthinking it...
timotimo m: my $to-match = "abc"; say "123abc987" ~~ / . $to-match . /
camelia 「3abc9」
moritz ggoebel: there is no special syntax for that; you might need to create the stringified variable outside of the regex
timotimo m: my @to-match = "abc", "xyz"; say "123abc xyz987" ~~ / . $(@to-match) . / 13:59
camelia 「3abc xyz9」
timotimo m: my @to-match = "abc", "xyz"; say "123abc xyz987" ~~ / . $(~@to-match) . /
camelia 「3abc xyz9」
timotimo this seems to work
moritz m: class A { method Str() { "abc" } }; my $x = A.new; say "fooabcd" ~~ /$x/ 14:02
camelia 「abc」
moritz seems to work fine
14:02 nige left, nige joined 14:03 harrison left
ggoebel my token x { 'abc' }; 'abc' ~~ /<x>/; if ('abc' ~~ /$<x>/) { say "1" } 14:04
doesn't work...
timotimo tokens are like subs and have & as their sigil 14:05
ggoebel my token x { 'abc' }; 'abc' ~~ /<x>/; my $x = ~$<x>; if ('abc' ~~ /$x/) { say "2" }
evalable6 2
ggoebel does
timotimo m: my token x { 'abc' }; say 'abc' ~~ /<x>/; if ('abc' ~~ / &x /) { say "1" } 14:06
camelia 「abc」
x => 「abc」
timotimo m: my token x { 'abc' }; say 'abc' ~~ /<x>/; if ('abc' ~~ / $&x /) { say "1" }
camelia 「abc」
x => 「abc」
14:06 nige left 14:07 nige joined
ggoebel does 14:07
thank you! 14:08
14:17 ape666 joined
notandinus moritz: i see, that's nice 14:18
14:18 frost-lab left 14:20 tankf33der joined 14:24 aindilis` left 14:25 aindilis joined 14:27 nige left, nige joined 14:30 leont joined 14:33 parabolize joined 14:35 wamba left 14:44 abraxxa left 14:46 ape666 left, nige left 14:47 nige joined, abraxxa1 joined 14:49 ape666 joined 14:50 ufobat joined
ggoebel timotimo: I don't think I'm fully understanding what you did with the token when you do $&x. If I am trying to match against what the token captured... how do I make the following work? 14:53
my token x { <:alpha>+ } my token y { <:alpha> <x> } if ('bc' ~~ /$(~$<y><x>)/) { say "ok" }
my token x { <:alpha>+ } my token y { <:alpha> <x> } say 'abc' ~~ /<y>/; if ('bc' ~~ /$(~$<y><x>)/) { say "ok" } 14:54
timotimo not sure if that's what you mean, but you can always $<blorp>=$<y> and then probably $/<blorp>
14:57 wamba joined
ggoebel m: my token x { <:alpha>+ } my token y { <:alpha> <x> } say 'abc' ~~ /<y>/; my $foo = ~$<y><x>; if ('bc' ~~ /$foo/) { say "ok" } 14:57
camelia 5===SORRY!5=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> 3my token x { <:alpha>+ }7⏏5 my token y { <:alpha> <x> } say 'abc' ~
expecting any of:
ggoebel m: my token x { <:alpha>+ }; my token y { <:alpha> <x> }; say 'abc' ~~ /<y>/; my $foo = ~$<y><x>; if ('bc' ~~ /$foo/) { say "ok" } 14:58
camelia 「abc」
y => 「abc」
x => 「bc」
14:58 tankf33der left
ggoebel is there a way to avoid declaring $foo and assigning ~$<y><x> to it? 14:59
15:01 BenGoldberg joined 15:02 nige left
ggoebel is there a way to avoid declaring $foo and assigning ~$<y><x> to it? 15:02
15:02 nige joined
dakkar m: my token x { <:alpha>+ }; my token y { <:alpha> <x> }; say 'abc' ~~ /<y>/; if ('bc' ~~ /<{~$<y><x>}>/) { say "ok" } # ggoebel 15:14
camelia 「abc」
y => 「abc」
x => 「bc」
Use of Nil in string context
in block at <tmp> line 1
5===SORRY!5=== Error while compiling /home/camelia/EVAL_0
Null regex not allowed
at /home/camelia/EVAL_0:1
------> 3anon regex { …
dakkar that explodes because the match object gets reset at the start of the match 15:15
15:15 Sgeo joined
dakkar m: my token x { <:alpha>+ }; my token y { <:alpha> <x> }; my $m = 'abc' ~~ /<y>/; if ('bc' ~~ /<{~$m<y><x>}>/) { say "ok" } 15:16
camelia ok
dakkar that works, because I saved the match object
ggoebel: does any of that help?
15:20 aluaces left 15:35 BenGoldberg left
guifa I know I’ve asked it before, but is there anyway to subclass Str? Mixins are (at least currently) a good bit slower than doing outright subclasses, so I’d love to be able to avoid them if possible 15:41
15:42 nige left, nige joined 15:43 ape666 left
ggoebel dakkar: thank you! 15:46
for both the solution and explanation dakkar++
15:47 ensamvarg3 left 15:48 wamba left, sjm_uk left
xinming m: role R { method t () { "R" }; }; class A does R { method t () { "A".say; }; }; A.new.t.say; 15:56
camelia A
16:01 sjm_uk joined 16:02 nige left, nige joined 16:06 nige left 16:07 nige joined 16:22 nige left, nige joined 16:24 patrickb joined 16:26 nige left 16:27 nige joined
patrickb timotimo: re relocatability on OpenBSD. Yes, OpenBSD lacks the mechanism to have relative paths in rpath. Doing relocatable builds on OpenBSD is actually forbidden in our build system for that very reason. 16:27
tellable6 2020-12-01T10:15:32Z #raku-dev <MasterDuke> patrickb github.com/pypa/pip/blob/master/.a...AMDisk.ps1 might be interesting to steal from
patrickb timotimo: There may be possibilities programmatically linking the files with dlopen or some such, but then you hit the next wall, that is reliably determining the absolute path of the currently running executable. 16:28
16:29 dataangel left, dataange` joined
patrickb The limitation of not being able to determine the executable path is known and Theo de Raadt considers it to be a too minor benefit and thus won't-fix. 16:30
16:42 jmchael joined 16:52 nige left, nige joined 16:56 nige left 16:57 nige joined
timotimo fair enough 17:04
17:06 Altai-man joined 17:07 abraxxa1 is now known as abraxxa 17:09 sena_kun left 17:14 ufobat left 17:22 skids joined 17:26 ggoebel left
brass Is there a way to convert a string to a regex? 17:28
I'm trying to do this 0x0.st/i745.txt 17:29
codesections brass: there are several ways :D I believe <$rx> may be the one you want 17:32
details at docs.raku.org/language/regexes#Reg...erpolation
brass codesections: Oh awesome!! Thank you! 17:33
17:34 dakkar left
brass btw, whoever wrote raku-mode for Emacs is an absolute Saint, I use it all the time :) 17:35
17:38 jmchael left 17:48 camelCaser joined 17:54 domidumont1 left 18:02 nige left, nige joined 18:03 aluaces joined 18:06 nige left 18:07 nige joined 18:14 patrickb left
timotimo $ain't 18:15
18:26 BenGoldberg joined
brass Is there a way to convert a match to an array of strings? 18:47
timotimo if you want to do that, perhaps you'd be better served by the "comb" method 18:49
brass I'm just trying to golf my advent of code question 18:50
timotimo OK, you can try putting a >>.Str after it
brass Beautiful! Thanks 18:52
18:52 nige left, nige joined 18:56 nige left 18:57 nige joined 18:58 orinthe left, orinthe joined 19:01 BenGoldberg left, wamba joined 19:11 orinthe left, orinthe joined 19:12 domidumont joined, orinthe left 19:13 orinthe joined 19:16 aluaces left, domidumont left 19:18 Xliff_ joined 19:19 Xliff left
holyghost I just started on the sequel of Game::Bayes, github.com/theholyghost2/p6-Game-Decision . it's decision theory based on Game::Stats and Game::Bayes where you use the stats from there 19:41
In a few weeks/months I will try to PR Game-Stats and Game-Bayes into some ecosystem 19:42
I still have to read the book about, finish it for building Bayes and Decision out 19:43
19:47 jmchael joined
holyghost I am working on 10 things at the same time, so be patient 19:56
20:02 jmerelo left 20:08 mowcat joined
codesections Raku doesn't have an easy way to both print and return a value, does it? 20:24
for example:
m: say(^5).map({$_+2}).sum 20:25
camelia ^5
codesections er
m: say (^5).map({$_ + 2}).sum
camelia 20
codesections if I wanted to inspect the value inside the map 20:26
m: say (^5).map({$_ + 2 ==> {.say; $_}()}).sum
camelia 2
codesections is the best I've come up with, but that's clunky enough that I miss Rust's dbg! macro 20:28
20:30 stoned75 left
codesections (which would be trivial to write myself in Raku, I know. But "while I'm print-debugging" isn't really a time when I want to be writing helper fns) 20:30
[Coke] worth writing up a debug module once and using that? 20:34
brass What's the ==>? 20:37
nvm found it docs.raku.org/language/operators#infix_==%3E 20:38
timotimo i don't know what "dbg!" does, but have you seen that module that offers "is traced"? 20:39
20:39 skids left
codesections yep that's the one (re: ==>) 20:39
Thanks, I'll take a look (it's not a big deal -- I mostly wanted to make sure I hadn't missed something built in) 20:41
(between all the ways we have to print something, I thought there might be one that returns something more useful than `True` :D ) 20:42
21:01 sjm_uk left
brass Is there an operator like ==> but that lets you use blocks instead of routines? 21:03
guifa [Coke]: unit module Debug::PrintReturn; sub print-return (\x) is export { print x; x }
^_^ 21:04
21:08 sena_kun joined, Altai-man left 21:12 brtastic1 joined 21:14 dataange` left 21:16 brtastic1 is now known as brtastic 21:19 nige left 21:41 brtastic left 21:44 Guest5249 joined 21:50 sena_kun left
brass Is mienaikage here? I have a question about their answer for day 2 :) 21:51
MitarashiDango[m Hi! 21:52
21:52 BenGoldberg joined
brass What do you call the prefix dot on this line? github.com/codesections/advent-of-...2.raku#L19 21:53
I assume it's something to do with grammars but I'm not sure where to look
guifa brass: That’s an implicit method call
brass OOOOOH
MitarashiDango[m Yup, its on the topic variable $_ 21:54
guifa basically if you ever see ‘.foo’, it really means $_.foo
brass I didn't know that you could do .<thing>
With the angle brackets
0x0.st/i7tD.raku :OOO 21:57
I had no idea!
guifa Works with all of the postfixes too
21:58 cpan-raku left
brass I've always accessed them directly using like %a<a>, not knowing it could be %a.<a> 21:58
That's really cool
perryprog ur really cool
brass :^)
21:59 cpan-raku joined, cpan-raku left, cpan-raku joined
guifa codesections: you’re welcome github.com/alabamenhu/DebugTransput 22:01
22:01 rindolf left 22:06 sena_kun joined 22:07 polettix joined 22:14 ensamvarg3 joined 22:20 mort joined 22:22 sena_kun left
mort Noob here, sorry. How can I iterate through the characters in a string? 22:23
brass .comb
Returns an array of all the characters from the string 22:24
mort oh, I didn't notice that one of the overloads for .comb is one which takes only the input string
guifa Also don’t forget Raku’s definition of character differs a little from other languages (I think swift is the only other one that works similarly).
mort I found .comb in docs.raku.org/type/Str#routine_comb, but also found .words which says it uses .comb, and found .comb which looked super complex so I assumed it was a low-level function which
guifa More just super versatile :-) 22:25
22:25 BenGoldberg left
Guest5249 but does it comb hair? 22:27
brass m: "hair".comb().say 22:28
camelia (h a i r)
Guest5249 nice!
guifa was going to make a joke about not combing too fast and use race, but ‘hair’ is too short to trigger out-of-order parallelization 22:31
cpan-raku New module released to CPAN! RogueGame (0.1.10) by 03KOBOLDWIZ 22:33
mort is there something wrong about using "eq in sink context"? Rakudo warns on the expression ($pass.comb[$p2] eq $ch)
the full statement is `return ($pass.comb[$p1] eq $ch) xor ($pass.comb[$p2] eq $ch);` 22:34
(yes, I'm using advent of code as an opportunity to try to learn raku) 22:35
22:35 Black_Ribbon joined
Geth ecosystem/alabamenhu-patch-1: 32ac9a1745 | L'Alabameñu++ (committed using GitHub Web editor) | META.list
Add Debug::Transport to list

See github.com/alabamenhu/DebugTransput
ecosystem: alabamenhu++ created pull request #571:
Add Debug::Transport to list
guifa facepalms. Not transport, transput hahaha 22:37
mort: careful about precedence 22:38
letter operators like xor have extremely low precedence
so what you’ve said is
mort sure, but even with parens literally everywhere like with `return (($pass.comb[$p1]) eq $ch) xor (($pass.comb[$p2]) eq $ch);` it still complains
guifa hmm 22:39
mort Useless use of "eq" in expression "($pass.comb[$p2]) eq $ch" in sink context (line 10)
apparently sink is raku's name for void, so it's in a void context? I thought xor was a binary operator? 22:40
Guest5249 that return is still the left operand of the xor
mort wat
so the statement is parsed as `(return (($pass.comb[$p1]) eq $ch)) xor (($pass.comb[$p2]) eq $ch)`? 22:41
sorry, I had too many (s somewhere, but you get the idea
guifa mort: correct 22:42
22:42 dataangel joined
mort well, you're right that adding parens to the whole expression fixes it. That's really weird to me though 22:42
guifa xor has EXTREMELY low precedence
MitarashiDango[m Try ^^ instead of xor
guifa you’re probably wanting ^^
mort I suppose I'm used to statement-oriented languages, where the general syntax for a return statement would be `return <expression>`, so as long as xor is at all an operator which can be part of an expression, it can't be lower "presedence" than the return keyword 22:43
guifa I can’t really think of a reason to use ‘xor’ to be honest. It was probably only done for parity with ‘and’ and ‘or’ which are useful
22:44 natrys left
mort are there times when it's useful to have an operator with a lower presedence than the return keyword? 22:44
guifa yeah 22:45
return $foo if $foo > 10
mort ah, that kind of infix if is an operator?
guifa actually, I think if in that case isn’t an operator
But I suppose with return there might be a case where your return expression results in a failure, and you could catch that with an `or` 22:46
mort does a return "expression" evaluate to the returned value? So that you could do like 'return do-something() or die', parsed as '(return do-something()) or die', where you die if do-something() evaluates to something falsey? 22:47
timotimo bisectable6: sub MAIN($a, $b --> Nil) { }
bisectable6 timotimo, Will bisect the whole range automagically because no endpoints were provided, hang tight
timotimo, Output on all releases: gist.github.com/2d39696a3851b4d781...09b3cc1f15 22:48
timotimo, bisect log: gist.github.com/92a9b8ace55143ee0e...eefa95a8fd
timotimo, Bisecting by output (old=2018.09 new=2018.10) because on both starting points the exit code is 2
timotimo, bisect log: gist.github.com/a688d006258a74cf22...c15d765e7e
timotimo, (2018-10-12) github.com/rakudo/rakudo/commit/7d...7a69bc97af
timotimo, Output on all releases and bisected commits: gist.github.com/472c8271c47ad6a92d...008a38544d 22:49
22:55 Guest5249 left
guifa I can’t seem to get a way to trigger an ‘or’ with with return 22:55
but it definitely fully exits the routine when it hits:
m: my $foo = ‘hi’; sub bar { $foo = return ‘bye’ }; bar; say $foo 22:56
camelia hi
guifa But my suspicions are correct, it’s implemented as a sub, rather than as a control flow word 22:59
m: say &return.WHAT
camelia (Sub)
timotimo .seen chloekek 23:03
tellable6 timotimo, I saw chloekek 2020-09-20T18:36:15Z in #raku: <chloekek> m: say (*).^name
guifa I’d guess that a lot of it has to do with the fact that it (and several others, like ‘redo’, ‘next’, or ‘take’) can take postfix control statements, which isn’t allowed for regular control statements 23:04
but I could be wrong, I wasn’t involved in the early design
23:04 xinming left 23:06 xinming joined
mort might just be an incidental result of other stuff, if there are other keywords which it does make sense to give a higher precedence than and/or, and it makes sense for return to be in the same category as those keywords, and it makes sense for xor to be in the same category as and/or 23:13
when making one strict ordering of the presence of every keyword, I suppose it's hard or impossible to make sure every single keyword pair's relative precedence makes sense in isolation 23:14
lizmat guifa: little in raku is really statement: most operators are really just subs 23:15
the only exception is really the short-circuiting || and && 23:16
SmokeMachine I was thinking... would that make sense if `done` could accept a optional parameter and if it received it, that would be returned by react? so, something like this `say react whenever Promise.in: 1 { done 42 }` would print 42 23:22
lizmat m: say react whenever Promise.in: 1 { done } 23:23
camelia Nil
lizmat m: say react whenever Promise.in: 1 { done 42 }