🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). 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 6 September 2022.
ToddAndMargo Any chanced in the future of you guys allowing me to declare more than one thing returned on the sub declaration?  Sort of like `sub FolderSize( Str $FolderPath --> Int, Str)  {` 00:53
Maybe I just don't know how?
vrurg ToddAndMargo: look for subset in the docs 01:49
ToddAndMargo I looked up subset.  Could not figure out what you meant.  I am returning an integer and a string 02:14
Nemokosch So you are returning a tuple? 07:18
Is there a way to tell a regex (or a grammar) "match any _permutation_ of these terms?" 09:45
guifa Nemokosch: if they can be in any order AND any number, [<a><b><c>]* 10:30
tellable6 guifa, I'll pass your message to Nemokosch
guifa if must be exactly 1
m: my $r = /[$<a>=a|$<b>=b|$<c>=c]* <?{$/<a b c>».elems.all == 1}> /; say so 'abc' ~~  $r; say so 'bac' ~~ $r; say so 'ba' ~~ $r; say so 'abbc' ~~$r;
camelia True
True
False
False
Nemokosch yeah rather the latter, thanks 10:33
guifa if your token is nothing more than the permutations, you could probably say something like (untested) $/.kv.grep(*.value.elems == 1) == $/.keys and you wouldn't need to update for each element in the list 10:38
guifa is afk
Geth advent: massa++ created pull request #95:
Update authors.md
11:19
Geth advent: 0f7f156d28 | (Humberto Massa)++ (committed using GitHub Web editor) | raku-advent-2022/authors.md
Update authors.md
11:51
advent: 87ff772234 | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | raku-advent-2022/authors.md
Merge pull request #95 from massa/patch-2

Update authors.md
SmokeMachine m: my @elems = <a b c>.permutations.map: *.join; say "cab" ~~ /^ @elems $/ 12:43
camelia 「cab」
Nemokosch this would explode pretty soon, right? 12:50
Xliff \o 19:15
Is there a way to use a Promise (or some other method) to implement a timeout on a method call? 19:16
Xliff m: my $colde = start { sleep 20; say "oops!" }; await Promise.in(2).then: { $code.break }; sleep 25; 19:24
camelia ===SORRY!=== Error while compiling <tmp>
Variable '$code' is not declared. Did you mean any of these: '$colde',
'Code'?
at <tmp>:1
------> "oops!" }; await Promise.in(2).then: { ⏏$code.break }; sleep 25;
Xliff m: my $code = start { sleep 20; say "oops!" }; await Promise.in(2).then: { $code.break }; sleep 25;
camelia An operation first awaited:
in block <unit> at <tmp> line 1

Died with the exception:
Access denied to keep/break this Promise; already vowed
in block at <tmp> line 1
Xliff m: my $code = start { sleep 20; say "oops!" }; my $v = $code.vow; await Promise.in(2).then: { $v.break }; sleep 25; 19:25
camelia Access denied to keep/break this Promise; already vowed
in block <unit> at <tmp> line 1
Xliff m: my $code = start { sleep 20; say "oops!" }; await Promise.in(2).then: { $code.break }; sleep 25;
camelia An operation first awaited:
in block <unit> at <tmp> line 1

Died with the exception:
Access denied to keep/break this Promise; already vowed
in block at <tmp> line 1
Xliff ??? Since when?
m: my $code = start { sleep 20; say "oops!" }; Promise.in(2).then: { $code.break }; sleep 25; 19:26
camelia (timeout)oops!
Xliff m: my $code = start { sleep 10; say "oops!" }; Promise.in(2).then: { $code.break; say "Broken" }; sleep 15; 19:27
camelia oops!
tonyo Xliff: you can't break a start {}
it'll leave that promise/code running and open if you time out that way 19:28
Xliff So how can I make the code block timeout.
tonyo are you running some long process in a loop or waiting on an external system in your start block?
Xliff Yep.
tonyo if a loop you can get away with a semaphore
if an external system then you need a different mechanism
Xliff OK. What system would you recommend?
Actually, I wonder if I am overthinking it.. .(probably) 19:29
tonyo what are you doing, specifically? 19:30
Xliff Trying to get a JSON response from a webservice/ 19:31
tonyo if you're doing a loop and the iterations are fairly short lived you can do:
m: my @timeout = (Promise.in(1); start { for 1..100 { die "cancel" if @timeout[0].status ~~ PromiseStatus::Kept; sleep 1; }; say "complete"; "done"; }); await Promise.anyof(|@timeout); @timeout.map({ $_.status ~~ PromiseStatus::Planned && $_.vow.break("timeout") }); await Promise.allof(@timeout); dd @timeout.map({ try { $_.result } // $_.cause }); 19:32
camelia (Bool::True, X::AdHoc.new(payload => "cancel")).Seq
Xliff So instead of NYI, I just use the timeout mechanism provided... LOL
tonyo for a web request there should be some timeout mech
haha yes
Xliff er...
s/NYI/NIH/
lizmat clickbaits rakudoweekly.blog/2022/10/24/2022-43-cro-apper/ 19:39