»ö« Welcome to Perl 6! | perl6.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: irc.perl6.org or colabti.org/irclogger/irclogger_log/perl6 | UTF-8 is our friend! 🦋
Set by Zoffix on 25 July 2018.
Juerd \o/ 00:14
lookatme_q o/ 00:18
Geth doc: uzluisf++ created pull request #2282:
Add missing letter
02:15
buggable New CPAN upload: AttrX-Mooish-v0.4.0.tar.gz by VRURG modules.perl6.org/dist/AttrX::Mooish:cpan:VRURG 02:42
Geth ecosystem: b8dad1f8d0 | (Nick Logan)++ (committed using GitHub Web editor) | META.list
Add CompUnit::Repository::Github

  💩
04:08
buggable New CPAN upload: AttrX-Mooish-v0.4.1.tar.gz by VRURG modules.perl6.org/dist/AttrX::Mooish:cpan:VRURG 06:02
perlawhirl bisectable6: my &f = *.elems; &f ∘= *.words; say f 'a b c'; 06:50
bisectable6 perlawhirl, On both starting points (old=2015.12 new=8275584) the exit code is 0 and the output is identical as well
perlawhirl, Output on both points: «1␤»
Geth doc: 7d214f6b98 | (Luis F. Uceta)++ | doc/Language/classtut.pod6
Add missing letter
08:02
doc: 46e71bf669 | Altai-man++ (committed using GitHub Web editor) | doc/Language/classtut.pod6
Merge pull request #2282 from uzluisf/master

Add missing letter
synopsebot Link: doc.perl6.org/language/classtut
pmurias hmm, what's a good way to check for a primality of a bigint? 09:27
timotimo you want to implement .is-prime on a new backend? rather than do it in perl6 where you could actually use .is-prime? 09:29
en.wikipedia.org/wiki/Miller%E2%80...ality_test - i think this is the one libtommath uses, so that's what rakudo has 09:30
pmurias I want to implement nqp::prime_I on the js backend
timotimo is there nothing on npm? ;) 09:31
pmurias I can't find anything
timotimo what? that's weird!
OK, then just™ use that primality test regex! :D :D :D 09:32
timotimo btw, it'd be really cool if someone took the stuff found in the "Deterministic variants" section of that article and made our primality testing faster 09:32
pmurias I use builtin BigInts which are a new thing
timotimo i mean the list of lines like if n < 341,550,071,728,321, it is enough to test a = 2, 3, 5, 7, 11, 13, and 17.
oh 09:33
ok, a paragraph above that says it's much slower in practice than using the probabilistic approach
timotimo never mind me, then! :) 09:33
pmurias timotimo: it would be like 100/7 times faster 09:34
pmurias for the n < 341,550,071,728,321 09:34
timotimo: is-prime has high number of Miller Rabin tests 09:35
timotimo on rakudo? yeah, way too high. 09:36
i'm reading a paper right now about a very fast test for 32bit integers 09:37
using that we wouldn't have to upgrade smallbigints to actual-bigints and do the miller-rabin on them
m: say 4 ** (-100) 09:38
camelia 6.223015277861142e-61
timotimo with 100 rounds, this is the probability of getting a false positive prime number
m: say 4 ** (-50)
camelia 7.888609052210118e-31
timotimo this is perhaps not good enough?
but something lower than 100 should suffice
pmurias timotimo: for all n < 3,317,044,064,679,887,385,961,981 just 13 steps is enought to be certain 09:45
(according to wikipedia)
timotimo i'm not entirely sure if that's how that is meant
timotimo m: say +"3,317,044,064,679,887,385,961,981".subst(",","").base(16) 09:46
camelia No such method 'base' for invocant of type 'Str'. Did you mean any of these?
Hash
asec
hash
take

in block <unit> at <tmp> line 1
timotimo m: say (+"3,317,044,064,679,887,385,961,981".subst(",","")).base(16)
camelia Cannot convert string to number: trailing characters after number in '033317⏏5,044,064,679,887,385,961,981' (indicated by ⏏)
in block <unit> at <tmp> line 1
timotimo m: say (+"3,317,044,064,679,887,385,961,981".subst(",","", :g)).base(16)
camelia 2BE6951ADC5B22410A5FD
pmurias timotimo: if n < 3,317,044,064,679,887,385,961,981, it is enough to test a = 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, and 4
moarvm tests those if you have 13 steps 09:47
timotimo oh?
ah, there's a miller-rabin-trials function that tells us how many we need 09:48
perhaps we should be calling that :) 09:49
lizmat clickbaits p6weekly.wordpress.com/2018/08/27/...kilfenora/ 10:47
scimon :) 10:54
Thanks to ilmari I have more stuff to do in Trait::Env 10:55
ilmari scimon: you're welcome ;-P 10:56
Altreus I feel like this is an idiom, but I don't understand it. github.com/croservices/cro-http/bl...t.pm6#L353 11:09
Can someone link me to something so I can understand it 11:10
?
What confuses me is that the promise resolves to a Response object but I don't know where that comes from 11:14
sena_kun Altreus, `emit`. 11:30
we use supply to stick in some `whenever` blocks w ewant, first one build pipeline async-way, next internal one sends a request and waits async-way. When the response is here, we emit it, it becomes first thing emitted from supply block and, hence, Promise is kept with this value. 11:32
s/build/builds/ 11:33
Altreus ah so .emit right down there, that emits the response right back up to the supply {} 11:35
maybe that's what someone meant about 2 months ago about how to refactor some of my code :D
sena_kun m: my $p = Promise(supply { whenever Promise.in(1) { emit 'Rize' } }); $p.then(*.result.say);
camelia ( no output )
sena_kun m: my $p = Promise(supply { whenever Promise.in(1) { emit 'Rize' } }); $p.then(*.result.say); sleep 2; 11:36
camelia Rize
sena_kun something like this, simplified.
Altreus, note that we have emit multiple times in code, based on if it's a possible redirect or some kind of error, but in fact it is always kept only once as no code path is ran twice. 11:38
Altreus I see :o 11:39
this is neat
So with Promise(supply ...) you can do a bunch of async stuff and finally .emit to keep the outer Promise
or die to break it 11:40
sena_kun m: my $p = Promise(supply { whenever Promise.in(1) { if 'Black' { die 'Bathory' } } }); $p.then(*.result.say); sleep 2; say $p.cause; 11:42
camelia Bathory
in block at <tmp> line 1
sena_kun Altreus, ^
so yes, that's about right. :)
Altreus most splendid
I can make use of this I think!
For example, dealing with Cro, I get a Promise from 'get' and that resolves to a Response... and then I get a Promise from .body on that and I really just want to return that Promise 11:43
So I think I can just repackage the body using Promise/supply
My brain is slowly being moulded to think async 11:46
sena_kun I am not sure right now, but I think just something like `$req.then(Promise(await *.result.body)).result` could work. But it's ugly enough imho. 11:46
Altreus I was gonna do Promise( supply { my $resp = await self.get ...; my $b = await $resp.body; .emit($b) } ) 11:48
sena_kun this stuff is tricky to get right, yes. but it's very nice afterwards.
Altreus (I subclassed Client so self has get)
sena_kun so you want to return the body promise or result of this promise? 11:49
your code is like second way, but `want to return that Promise` sounds like first to me.
Altreus I figured it was easier to repackage the body promise into a new promise 11:50
your way is a bit shorter, though
returns the real body promise 11:51
hmm
sena_kun well, it's up to you, though I am not sure why repackage. maybe if you want to patch the body somehow, but keep it async-y way.
Altreus I don't really want to :) I'll try your way 12:02
oh hold on yours repackages the body too :) 12:03
no wait
it puts a promise in another promise
Altreus wouldn't it just be $req.then(*.result.body) 12:04
sena_kun it will be.
sena_kun `$req.then(*.result.body).result` I think, to unwrap Promise created with `then`. 12:05
Altreus but that blocks no? 12:06
sena_kun have you tried that? I don't know to be honest, doing another thing right now. :) 12:07
anyway, that's a way to experiment a bit, I hope the general approach on how Cro does it is now a bit more clear. 12:08
Ven` masak: well, nothing was happening, so I was wondering wtf was going on
i just typed to try and get it to move. I do like relative numbering otherwise :) 12:09
Altreus sena_kun: yes indeed, thanks :) 12:12
buggable New CPAN upload: Text-I18n-0.1.0.tar.gz by TYIL cpan.metacpan.org/authors/id/T/TY/...1.0.tar.gz
jnthn start (await $resp).body # probably the shortest way to make an async thing that evaluates to the body Promise 12:14
Altreus jnthn: I feel like I'm missing a part. Surely (await $resp).body is a Promise, and then start is another Promise? 12:34
So my method returns a Promise that resolves to a Promise that resolves to the body
But I don't want to await directly inside the method because that'll block
jnthn oops, yes, I meant `start await (await $resp).body`, sorry :) 12:37
I've also been pondering a .get-body for folks doing really simple things to avoid some boilerplate. 12:38
sena_kun m: say '$req.then(*.result.body).resul'.chars eq 'start await (await $resp).body'.chars
camelia True 12:39
timotimo hah
actually, you don't want the .result at the end there, i think
sena_kun though the variable name is different, so +1 char. :S
jnthn Yes, but .result is blocking, and await with use v6.d.PREVIEW is non-blocking
sena_kun runs away 12:40
Altreus aha I do understand! 12:41
That's grand
alright I have to drive a whole bunch now, but thanks for all your helps :)
buggable New CPAN upload: I18n-Simple-0.1.0.tar.gz by TYIL cpan.metacpan.org/authors/id/T/TY/...1.0.tar.gz 12:42
buggable New CPAN upload: String-Fold-0.1.1.tar.gz by TYIL modules.perl6.org/dist/String::Fold:cpan:TYIL 14:42
buggable New CPAN upload: String-Fold-0.1.2.tar.gz by TYIL modules.perl6.org/dist/String::Fold:cpan:TYIL 14:52
Geth doc: d635ba72e5 | (JJ Merelo)++ | doc/Language/glossary.pod6
Reflows and fixes links

Refs #561 #1838, but mainly it's been a very extensive reflow, there were very long lines here. Main intention was to work towards #2283
17:01
synopsebot Link: doc.perl6.org/language/glossary
Geth doc: 0346c606c6 | (JJ Merelo)++ | doc/Language/glossary.pod6
Fixes link to Roles

This closes #2283. This link is probably better, since it's the declarator. The problem is that it maybe is the symptom for a problem, namely, /syntax/role generated at one particular point in time and no longer there for some fluke of the page generation. So thanks a lot for the report, and I'll investigate if that's the case.
doc: 2a5d0b94b5 | (JJ Merelo)++ | doc/Language/glossary.pod6
More reflowing and minor changes
17:08
synopsebot Link: doc.perl6.org/language/glossary
pukku Hi! Is there anything special about an autogenerated parameter using the "thorn" character? In particular, I am looking at the docs for `==>` on docs.perl6.org. 17:19
MasterDuke pukku: i don't think so. i believe $^þ was used just to show that using unicode chars in variable names is no big deal 17:22
pukku Cool; I just wanted to make sure that I wasn't missing something. 17:23
pukku I found a weird oddity, and was wondering if there was a reason, or if I've just run into an edge case. I've tried searching via Google and DDG, but nothing seems to be coming up. If you try creating a list of hashes via `@foo.map( { { 't' => $_ }; })`, you get back just a list of pairs. You need to do `@foo.map( { %( 't' => $_ ); })` to get back a list of hashes. (Also, if you try `%{...}`, it crashes.) 18:03
tobs m: <1 2 3 4>.map({ { t => $_ }.WHAT }).perl.say 18:14
camelia (Block, Block, Block, Block).Seq
tobs pukku: it mistakes the inner braces for a block which it executes
pukku Is there a better idiom for creating a list of hashes in Perl 6? 18:17
tobs I think %(t => $_) is fine 18:22
That's also the one listed in docs.perl6.org/language/syntax#Hash_literals
tobs pukku: further reading :-) github.com/perl6/doc/issues/2117 and stackoverflow.com/a/44102980 18:31
m: ^4 .map({ hash t => $_ }).perl.say # also neat if you ask me 18:37
camelia ({:t(0)}, {:t(1)}, {:t(2)}, {:t(3)}).Seq
pukku m: ^4.map({foo => $_}).perl.say 18:41
camelia Potential difficulties:
Precedence of ^ is looser than method call; please parenthesize
at <tmp>:1
------> 3^47⏏5.map({foo => $_}).perl.say
(:foo(4),).Seq
WARNINGS for <tmp>:
Useless use of "^" in expression "^4.map({foo …
pukku m: <1 2 3 4>.map({ {t=>$_} }).perl.say 18:41
camelia (:t(IntStr.new(1, "1")), :t(IntStr.new(2, "2")), :t(IntStr.new(3, "3")), :t(IntStr.new(4, "4"))).Seq
pukku Why in the world does quoting hash keys break everything? According to the stack overflow link, quoting a hash key changes a (potential) hash into a block, and you can't put quotes around named parameters in function calls. 18:44
tobs m: ^4 .map({ { t => $_ } }).perl.say; ^4 .map({ { t => 42 } }).perl.say 18:51
camelia (:t(0), :t(1), :t(2), :t(3)).Seq
({:t(42)}, {:t(42)}, {:t(42)}, {:t(42)}).Seq
tobs I bet it's the usage of $_ which make the braces into a code block 18:52
pukku OK, that's even more confusing. But I guess I'll just use the `%(...)` form for now, and at least the program will work. Thanks!
uzl \o/ 19:01
yoleaux 27 Aug 2018 16:28Z <MasterDuke> uzl: "We’ll build from the most simple category, the assignment category to the most general one, the course category.", there should probably be some sort of punctuation after "assignment category"
27 Aug 2018 16:30Z <MasterDuke> uzl: "not zeroth" should be "no zeroth"
27 Aug 2018 16:31Z <MasterDuke> uzl: your `class Assignment {` code example has some weird indentation for the comments
27 Aug 2018 16:35Z <MasterDuke> uzl: the bullets have a different font size in the Assignment Class paragraph vs the Student Class paragraph
27 Aug 2018 16:36Z <MasterDuke> uzl: "a add-assignment method" should be "an add-assignment method"
27 Aug 2018 16:37Z <MasterDuke> uzl: "but can we can" has an extra 'can', should be "but we can"
27 Aug 2018 16:38Z <MasterDuke> uzl: "but can we can" has an extra 'can', should be "but we can"
27 Aug 2018 16:40Z <MasterDuke> uzl: actually, a bunch of the code samples have odd formatting for the comments
27 Aug 2018 16:43Z <MasterDuke> uzl: `if ($number ~~ s/^E//) {`, the "superstitious" parens in the `if` conditional are generally not used in perl 6
27 Aug 2018 16:44Z <MasterDuke> uzl: this could be a personal preference thing, but `$number = $number.Int;` could also be written as `$number .= Int;`
27 Aug 2018 16:48Z <MasterDuke> uzl: another personal preference thing, but `unless $!type eq 'Homework' or $!type eq 'Exam' {` could be `unless $!type eq 'Homework' | 'Exam' {`
27 Aug 2018 16:49Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 16:50Z <MasterDuke> uzl: "add a a formatted-score", doubled "a"
27 Aug 2018 16:53Z <MasterDuke> uzl: "add a a formatted-score", doubled "a"
27 Aug 2018 16:53Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 16:55Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 17:02Z <MasterDuke> uzl: "looks the Student object for that student and adds assignment to it.", maybe a missing "up" after "looks" and a missing "an" before "assignment"
27 Aug 2018 17:16Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 17:49Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 23:42Z <MasterDuke> uzl: `unless %!config{$!type}[$!number] {`, most of your hash accesses have spaces around the variable
27 Aug 2018 23:42Z <MasterDuke> uzl: "looks the Student object for that student and adds assignment to it.", maybe a missing "up" after "looks" and a missing "an" before "assignment"
11:46Z <MasterDuke> uzl: i don't think `grep: { $_ }` does what you want (if i understand what you're trying to do). e.g., it will exclude array elements where the value is 0. maybe `grep: *.defined` ?
11:52Z <MasterDuke> uzl: this would also depend on what exactly you want to do, but `%!assignments<Homework>[1..*]` could also be `%!assignments<Homework>.skip`. using skip give you a Seq instead of an array, so that might not work in all cases though
12:03Z <MasterDuke> uzl: you have a comment `# CLI arguments are stored in @*ARGV`, but then do correctly use `@*ARGS` in the code
12:04Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
12:07Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
12:07Z <MasterDuke> uzl: "this doesn’t make them justice.", should be "this doesn’t do them justice."
12:08Z <MasterDuke> uzl: "a compile-time error will be trown.", typo there, should be "a compile-time error will be thrown."
12:08Z <MasterDuke> uzl: "this doesn’t make them justice.", should be "this doesn’t do them justice."
12:08Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
12:10Z <MasterDuke> uzl: ".^attributes - returns all the methods that can be called on the object.", should be something like ".^attributes - returns all the attributes of the object."
12:15Z <MasterDuke> uzl: ".^attributes - returns all the methods that can be called on the object.", should be something like ".^attributes - returns all the attributes of the object."
12:54Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
15:02Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
17:20Z <MasterDuke> uzl: "courses a student has been enrolled on.", should be "enrolled in."
geekosaur you only live thrice? 19:06
lindylex Why does this split the numbers larger than 255 numbers into two and make them test positive? say "27.36.1.255 77 999.569.22.40".match(/ \d ** 1..3 <?{ $/ >= 0 && $/ < 256 }> /, :global); 19:17
geekosaur lindylex, because patterns don't read your mind. if you base them on characters like that, it breaks on characters. so if reading 3 characters causes it to fail on a result based om <256, it will try again with 2, pass, and then read the remainder as a new number 19:30
uzl .tell MasterDuke `if ($number ~~ s/^E//) {`, I don't remember the error correctly but I was getting something related to globbing, which was fixed after adding the parenthesis. It was probably not related though. 19:31
yoleaux uzl: I'll pass your message to MasterDuke.
uzl .tell MasterDuke I usually put the spaces around the variables in the hash accesses to make them easier to read. Are there occasions when these spaces make a difference? 19:32
yoleaux uzl: I'll pass your message to MasterDuke.
geekosaur you need to prevent the (\d ** 1..3) from backtracking, so it commits to a digit string before testing its value instead of backtracking through it if the value test fails
lindylex geekosaur : this is <?{ $/ >= 0 && $/ < 256 }> should have tested the number found.
geekosaur you;re missing my point
it does
and then it fails, and then the regex backtracks through \d ** 1..3, trying 2 instead of 3, and the subsequent test succeeds 19:33
lindylex Oh I see.
I get it now,
uzl .tell MasterDuke `grep: { $_ }`. The thing is that the array shouln't be a number but an Assignment object. `%!assignments<Homework>[1..*]` is meant to skip the zeroth element (a whole number) which keeps tracked of the number of assignments. I didn't know about `.skip` so I'll look into it.
yoleaux uzl: I'll pass your message to MasterDuke.
uzl .tell MasterDuke I don't know why but I always get ARGS and ARGV (which I think isn't a thing in P6) confused. Anyway...Thanks for taking the time to proofread it. Really appreciate it. I've updated the post to reflect your corrections. 19:34
yoleaux uzl: I'll pass your message to MasterDuke.
geekosaur lindylex, the easiest fix for this is probably to make \d ** 1..3 a separate token definition, which prevents backtracking through it by default 19:35
(see :ratchet)
lindylex geekosaur : thanks say "27.36.1.255 77 999.569.22.40".match(/ :r \d ** 1..3 <?{ $/ >= 0 && $/ < 256 }> /, :global); 19:51
TimToady lindylex: also see colabti.org/irclogger/irclogger_log...08-23#l713 which you missed by a hair
geekosaur I thought that sounded familiar... 19:52
lindylex brb thanks all. 19:55
TimToady
.oO( so if the last brb lasted 5 days... :)
19:58
diakopter
.oO( belated return believed )
20:12
buggable New CPAN upload: I18n-Simple-0.1.1.tar.gz by TYIL modules.perl6.org/dist/I18n::Simple:cpan:TYIL 21:42
MasterDuke oops, looks like yoleaux did get all my messages, even though it didn't always reply to me 23:12