🦋 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.
[Coke] wonder if it has something to do with the way cross is defined 00:08
m: dd &cross
camelia Sub+{is-pure}+{Precedence} infix:<X> = proto sub infix:<X> (|) {*}
[Coke] (it's an alias to infix<X>
m: dd cross(<1 2 3>, <4 5 6>); my @params=(<a b c>,<d e f>); dd cross(@params[0], @params[1]); 00:09
camelia ((IntStr.new(1, "1"), IntStr.new(4, "4")), (IntStr.new(1, "1"), IntStr.new(5, "5")), (IntStr.new(1, "1"), IntStr.new(6, "6")), (IntStr.new(2, "2"), IntStr.new(4, "4")), (IntStr.new(2, "2"), IntStr.new(5, "5")), (IntStr.new(2, "2"), IntStr.new(6, "6"))…
[Coke] m: say cross(<1 2 3>, <4 5 6>); my @params=(<a b c>,<d e f>); say cross(@params[0], @params[1]);
camelia ((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6))
(((a b c) (d e f)))
[Coke] m: say cross(<1 2 3>, <4 5 6>); my @params=(<a b c>,<d e f>); say cross(@params[0].List, @params[1].List); 00:10
camelia ((1 4) (1 5) (1 6) (2 4) (2 5) (2 6) (3 4) (3 5) (3 6))
((a d) (a e) (a f) (b d) (b e) (b f) (c d) (c e) (c f))
[Coke] m: my @params=(<a b c>,<d e f>); dd @params[0];
camelia List @params = $("a", "b", "c")
[Coke] tagging lizmat, as I know she just found a case where dd was pretending to be a type it wasn't. :) 00:11
tj94 After looking at the dd outputs, it seems like the list is being flattened when being passed in as @params = (<1 2 3>, <4 5 6>); 00:21
Any tricks to keep the list from being flattened ?
my @params = (<1 2 3>, <4 5 6>);dd @params; 00:24
evalable6 Array @params = [(IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3")), (IntStr.new(4, "4"), IntStr.new(5, "5"), IntStr.new(6, "6"))]
tj94 output:
Array @params = [(IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3")), (IntStr.new(4, "4"), IntStr.new(5, "5"), IntStr.new(6, "6"))]
dd (<1 2 3>, <4 5 6>);
evalable6 ((IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3")), (IntStr.new(4, "4"), IntStr.new(5, "5"), IntStr.new(6, "6")))
tj94 output: 00:25
((IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(3, "3")), (IntStr.new(4, "4"), IntStr.new(5, "5"), IntStr.new(6, "6")))
Thank you !! Looks like you solved it with: 00:33
my @params = (<1 2 3>, <4 5 6>, <7 8 9>);
cross(@params.List);
tbrowder another class question, please: give class A with attribute $!value, class B is A: is there any way to acess $!value from an instance of B? 00:44
*given...
jmerelo m: my $rx = "(.*)a(.*)b(.*)" 06:15
camelia ( no output )
jmerelo m: my $rx = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/<$rx>/
camelia 「xaybz」
jmerelo m: my $rx = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/$rx/
camelia Nil
jmerelo m: my $rx = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/\qq[$rx]/ 06:18
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized backslash sequence: '\q'
at <tmp>:1
------> 3 = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/\7⏏5qq[$rx]/
jmerelo m: my $rx = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/<\qq[$rx]>/
camelia 5===SORRY!5===
Unrecognized regex metacharacter < (must be quoted to match literally)
at <tmp>:1
------> 3 = "(.*)a(.*)b(.*)"; say 'xaybz' ~~ rx/<7⏏5\qq[$rx]>/
Unrecognized regex metacharacter \ (must be quoted to match literally)
jmerelo m: my $rx = "\qq[(.*)a(.*)b(.*)]"; say 'xaybz' ~~ rx/<$rx>/ 06:19
camelia 「xaybz」
jmerelo m: my $rx = "\qq[(.*)a(.*)b(.*)]"; say 'xaybz' ~~ rx/$rx/
camelia Nil
jmerelo m: my str $str = "\qq[(.*)a(.*)b(.*)]"; say Regex.new( :$str ) 06:24
camelia Cannot make a Regex object using .new
in block <unit> at <tmp> line 1
jmerelo m: my str $str = "\qq[(.*)a(.*)b(.*)]"; say Method.new( :source($str) ) 06:25
camelia Cannot make a Method object using .new
in block <unit> at <tmp> line 1
jmerelo m: my $rx = "(.*)a(.*)b"; say 'xaybz' ~~ rx/<$rx>/ 06:30
camelia 「xayb」
jmerelo Hum
m: my $rx = '(.*)a(.*)b(.*)'; say 'xaybz' ~~ rx/<$rx>/ 06:31
camelia 「xaybz」
jmerelo m: my $rx = '(.*)a(.*)b\(.*\)'; say 'xaybz' ~~ rx/<$rx>/
camelia Nil
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; say 'xaybz' ~~ rx/<$rx>/ 06:32
camelia 「xaybz」
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; say 'xaybz' ~~ rx/$rx/
camelia Nil
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; say $rx.Str
camelia (.*)a(.*)b(.*)
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; say 'xaybz' ~~ rx/$<result>=<$rx>/; say $result 06:33
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$result' is not declared
at <tmp>:1
------> 3say 'xaybz' ~~ rx/$<result>=<$rx>/; say 7⏏5$result
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; say 'xaybz' ~~ rx/$<result>=<$rx>/; say $<result>
camelia 「xaybz」
result => 「xaybz」
0 => 「x」
1 => 「y」
2 => 「z」
「xaybz」
0 => 「x」
1 => 「y」
2 => 「z」
jmerelo m: my $rx = '(.*)a(.*)b(.*)'; 'xaybz' ~~ rx/$<result>=<$rx>/; say $<result> 06:34
camelia 「xaybz」
0 => 「x」
1 => 「y」
2 => 「z」
jmerelo m: say :key( { value => 1, another-value => 2 } ) 08:31
camelia Unexpected named argument 'key' passed
in block <unit> at <tmp> line 1
jmerelo m: my %associative = :key( { value => 1, another-value => 2 } ); say %associative
camelia {key => {another-value => 2, value => 1}}
tbrowder .ask jkramer can you please help or advise direction with File::Copy for allowing copy file to dir 11:46
tellable6 tbrowder, I'll pass your message to jkramer
lizmat and another Rakudo Weekly News hits the Net: rakudoweekly.blog/2020/10/19/2020-42-recipes/ 14:01
tyil lizmat++
moritz lizmat++ indeed 14:06
[Coke] finds a link to www.apress.com/gp/book/9781484262573 - clicks on math preview. Coke cannot figure out what the "hair at the neck" comment is in relation to. :| 14:52
(like, I get it as a standalone Note. I have no idea what it's doing there.)
El_Che I don't see any hair of neck references 14:54
jdv79 its in the "Note" call out thing 14:56
moritz that's in reference to the story about doubling the amount of ground for each square on the chess board
jdv79 its also lost on me 14:57
lizmat congratulates moritz with twitter.com/taustation/status/1318...3721506816 :-) 14:58
[Coke] ahhhh 14:59
thank you for finding the reference, moritz. :)
Didn't see the "king" item in the main text before, must have skimmed.
El_Che jmerelo: your book is wrongly categorized as "Shell Scripting" in O'Reilly Safari: strasbourg.apt-get.be/f/de1ecd3ed1b94128a11f/ 15:00
Altreus I have a Cro::WebSocket::Client object, which has a closer promise. Then I have «whenever $conn.closer -> $c» to handle the websocket closing, which seems to work 15:08
The problem is that $c appears to be a promise, even if I call $c.result
And $c.result.result
I can't work out what I've done wrong
timotimo i mean, it's valid to set a promise's result to another promise :D 15:17
Altreus yeah but
it's not :D
it's kept with either a string or a message object AFAICT 15:20
timotimo i'll have a quick look at the code
Altreus github.com/croservices/cro-websock...ection.pm6 15:21
84 and 104
And here is where I handle it, only without my new changes to accept $c github.com/shuppet/p6-api-discord/...akumod#L90 15:24
timotimo yeah line 84 closes the closer with itself as the value 15:25
Altreus oh
that seems silly
timotimo so you'll get $c.result result in $c, so you can infinitely .result and get the same thing every time
Altreus I think it intends to use the message
timotimo yeah that looks like an accident
yeah
Altreus i fix locally
make pr
get famous for contributing
:D
timotimo good 15:27
Altreus uh I fixed it and now it's not closing any more 15:28
timotimo what does your fix look like, then? :)
Altreus $!closer.keep($_) if $!closer;
timotimo yeah that's not correct tho :)
Altreus I mean
wait I wanted .defined 15:29
or not at all
timotimo yes defined
Altreus it should be defined I think
jmerelo El_che oh no 15:34
El_Che: perl legacy is still following us... 15:35
Altreus github.com/croservices/cro-websocket/pull/30 ta-da 15:36
never mind, beaten by a bot
[Coke] m: my $closer; $closer?.keep('eek') 15:40
camelia 5===SORRY!5=== Error while compiling <tmp>
Bogus postfix
at <tmp>:1
------> 3my $closer; $closer7⏏5?.keep('eek')
expecting any of:
infix
infix stopper
statement end
statement modifier
[Coke] m: my $closer; $closer.?keep('eek') 15:41
camelia ( no output )
[Coke] ^^
m: my $closer; $closer.keep('eek') #vs
camelia No such method 'keep' for invocant of type 'Any'. Did you mean any of
these: 'grep', 'keys'?
in block <unit> at <tmp> line 1
Altreus m: my $closer = Promise.new; $closer.break; $closer.?keep('eek'); 15:45
camelia Access denied to keep/break this Promise; already vowed
in block <unit> at <tmp> line 1
Altreus bah 15:46
timotimo yeah, .? is for if you don't know if the method exists 16:00
Altreus oya 16:07
well that's kind of the case but not really the semantics
[Coke] timotimo: it also protects against undefined LHS. 16:13
timotimo oh?
[Coke] ... hurm. depending on level of undefined.
timotimo m: say Str.?chars 16:14
camelia Use of uninitialized value of type Str in string context.
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful.
0
in block <unit> at <tmp> line 1
[Coke] if it's an Any, it'll DTRT. if it's a class object, then you might still end up invoking it. Yah, nevermind.
timotimo maybe you were thinking of Nil, which "has every method"
[Coke] I'm used to it being used as like a nil protector in other languages, my bad.
Doc_Holliwood is there a good way to count the number of things in a list that satisfy a condition? 16:20
i'm not interested in the things themselves, only the count
if not, how about @things.grep( * < 1, :c ) # :c for count 16:21
or @things.elems( * < 1 )
lizmat sorta recalls implementing something like that
Doc_Holliwood is sorta happy to hear that 16:22
lizmat looks at the code and doesn't see it :-( 16:23
Doc_Holliwood oh and what the heck does "Malformed postfix call (only alphabetic methods may be detached)" mean
i'm trying to use a sub as in my &x = * + 1; @things.&x but it blow with that error 16:24
@things.grep.&x rather
lizmat m: my @a = ^100; my int $count; @a.grep: { ++$count if $_ %% 3; False }; say $count # Doc_Holliwood 16:25
camelia 34
lizmat pretty sure that's pretty fast as the False makes sure no values are actually produced by the Seq
Doc_Holliwood that's uglier than the american president :D
lizmat making $count an atomic int, you could even hyper it 16:26
Doc_Holliwood it also has a side effect 16:27
but thanks 16:28
still thinking though, that should be builtin
dakkar m: my @things=1..10; say 0+@things.grep({ $_ %% 2 })
camelia 5
dakkar like that?
lizmat dakkar: you don't need the 0 for that
Doc_Holliwood yes, but that still produces the elements of the sequence
dakkar oh right, `+` is not a nop in rake
SmokeMachine m: my @a = ^100; say @a.grep({ $_ %% 3 }).elems # while not simply this? 16:33
camelia 34
lizmat SmokeMachine: that works, but is wasteful CPU wise, because it still produces all the values that match the condition 16:34
lizmat and then counts the number of elems in the resulting Seq 16:35
and since the iterator is not a PredictiveIterator, that means producing all of the values :-(
SmokeMachine it's a Seq, couldn't it not produce the values it .elems is called (as Red does?) 16:36
lizmat it can only do that reliably if it is a PredictiveIterator 16:37
lizmat please check github.com/rakudo/rakudo/blob/mast...eq.pm6#L58 16:38
SmokeMachine but can't `Seq.grep(&cond).elems` be equivalent to `my $count = 0; Seq.grep: { $count++ if cond($_); False }`? 16:41
lizmat lemme see what breaks if I do that :-) 16:43
SmokeMachine :) 16:44
lizmat building now 16:46
I think I remember now why that won't work: 16:47
it's very easy, under the hood, to create this situation: if foo.elems { for foo { ... } }
if .elems already exhausts the Seq, the for won't work
SmokeMachine but would the if be needed on that case? if there is no elements, the for won't loop... 16:51
I know that's not related, Rakudo's seq are much deeper than Red's ResultSeq, but just because I like the way it works: usercontent.irccloud-cdn.com/file/.../image.png 16:52
lizmat gist.github.com/lizmat/2b0975d71d5...a10bae452f # SmokeMachine: the result 16:54
SmokeMachine lizmat: I'm not suggesting that, but does the errors stop if you .cache it before .elems? (I now that's not a fix... I'm just curious (I can test it here if you are not curious enough)) 16:57
lizmat but the .cache is exactly what we're trying to prevent ? 16:58
and yes, I've lost my curiosity there, been there, tried that and failed again now :-)
SmokeMachine I assumed the error on the tests were because it was trying to use the now exhausted Seq... 16:59
lizmat SmokeMachine: yup 17:16
SmokeMachine So that’s why I’m going to test caching it, if all tests pass, that’s the only problem... 17:17
lizmat SmokeMachineL: not sure what you're trying to achieve, but don't let that stop you :-) 17:20
SmokeMachine :) 17:22
But I think I’ll have to leave that to a future test... (I should be fixing Red bugs) 17:23
Geth doc: olorin37++ created pull request #3669:
Correct typo
19:32
Geth doc: f247ee4cd2 | (Jakub A. G)++ (committed using GitHub Web editor) | doc/Language/haskell-to-p6.pod6
Correct typo
19:37
doc: 2e85facd96 | (Will Coleda)++ (committed using GitHub Web editor) | doc/Language/haskell-to-p6.pod6
Merge pull request #3669 from olorin37/patch-2

Correct typo
linkable6 Link: docs.raku.org/language/haskell-to-p6