🦋 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.
guifa leont: is it something you’re going to use regularly? Then you could make a custom operator that you could use with Z 00:16
MasterDuke i think there was some discussion about that exact question recently (within the past month or so), but i can't find it 00:29
rypervenche There was something similar that Jonathan wrote, but I couldn't get it to work. Something like @a Z[&({$^b($^a)})] b . But yeah, I think a custom operator may be a cleaner approach. 00:36
vrurg m: sub foo($s) { $s*2 }; say (1,2,3) Z[&(-> $a, $b {$b.($a)})] &foo xx * 01:27
evalable6 (2 4 6)
vrurg rypervenche: ^^ something like this. 01:28
m: sub foo($s) { $s*2 }; say (1,2,3) X[&(-> $a, $b {$b.($a)})] &foo
evalable6 (2 4 6)
rypervenche Ahhhh, it needs a lambda. 01:32
cfa rypervenche: this is fine too, 01:35
m: sub foo($s) { $s*2 }; say (1,2,3) Z[&({$^b.($^a)})] &foo xx *
evalable6 (2 4 6)
cfa per your original 01:36
as is
m: sub foo($s) { $s*2 }; say (1,2,3) Z[&({$^b($^a)})] &foo xx *
evalable6 (2 4 6)
cfa or, ofc 01:38
m: say (1, 2, 3) Z[&({$^b($^a)})] { $_ * 2 } xx *
evalable6 (2 4 6)
cfa m: say (1, 2, 3) Z[&({$^b($^a)})] (* * 2) xx * 01:39
evalable6 (2 4 6)
cfa shuts up 01:40
vrurg rypervenche: it also works with $^b, $^a. Pointy block in my case is an artifact of experimenting. 01:45
m: sub foo($s) { $s*2 }; say (1,2,3) X[&({$^b.($^a)})] &foo
evalable6 (2 4 6)
vrurg Oh, I should've read what cfa was writing. :D
rypervenche m: my @values = <one two three>; say @values X[&({$^b($^a)})] &uc 01:54
evalable6 (ONE TWO THREE)
rypervenche Ahhh, I see. I needed the & there.
How would one put something like &uc into an array? and then use an array at the end instead? I keep getting errors. 01:56
cfa vrurg: :P 01:58
vrurg m: say (&uc xx 3).raku 01:59
evalable6 (proto sub uc ($, *%) {*}, proto sub uc ($, *%) {*}, proto sub uc ($, *%) {*}).Seq
vrurg rypervenche: like this, for example.
rypervenche: &foo is a Callable object (Code and derivates). 02:00
cfa rypervenche: what are you trying to achieve, exactly? 02:03
rypervenche: store a collection of functions to apply later?
rypervenche Oh, I was missing parentheses. All good then. Just trying to do what the original question was. 02:09
vrurg rypervenche: parentheses are there only to invoke .raku on the resulting list. xx creates a list on its own. 02:14
m: my $a := &uc xx 3; say $a
evalable6 (&uc &uc &uc)
vrurg m: my $a := &uc xx 3; say $a.raku
evalable6 (proto sub uc ($, *%) {*}, proto sub uc ($, *%) {*}, proto sub uc ($, *%) {*}).Seq
leont guifa: not really, though I have seen someone ask for the same operator a few weeks ago 08:48
leont m: say NaN == NaN; say NaN === NaN 09:44
evalable6 False
True
leont That seems surprising, it that a bug or a feature? 09:45
I would argue bug 09:47
leont Both are logical in their own right, but the combination seems confusing 09:49
tyil hmm 12:19
I have a small raku script here, which throws a big error if I run it with `| head -n 3` 12:20
about a broken pipe
tyil I cannot post the script or its output, but I can post the error 12:20
p.tyil.nl/uk0k
piped through wc -l shows there's 71678 lines in the actual output 12:21
leont Yeah, that is a known issue 12:34
I'm sure I posted a solution a while ago, but I'm not sure I saved it 12:35
«use NativeCall; sub signal(int32, int64) is native { * }; signal(SIGPIPE, 0);» 12:38
It will ensure the default unix behavior in such cases, which is the right thing for command line tools and the wrong thing for network applications 12:49
tyil interesting 13:03
thanks leont
leont Raku defaults to the opposite, basically 13:04
lizmat tyil: could it be that the module upload bot is down ? 13:08
tyil cpan-raku is in this channel 13:09
tyil logs show it saw voldenet change host just now as well 13:10
is it not reporting a module you uploaded? 13:11
lizmat just uploaded a module twice, and it has been reported on Twitter already :)
tyil hmm
give me a few moments to do some work related stuff
then I'll take a look :>
lizmat no hurry... just noticing...
tyil lizmat: which module are you referring too? 13:24
twitter doesn't let me read anything without accepting js trackers these days
so I can't check there
lizmat ValueTypeCache 13:25
tyil ty
lizmat 0.01 and 0.02
cpan-raku New module released to CPAN! ValueTypeCache (0.0.2) by 03ELIZABETH 13:27
New module released to CPAN! ValueTypeCache (0.0.1) by 03ELIZABETH 13:28
tyil both the nntp and rsync services to check for new modules seem to be having issues on my end
cpan-raku New module released to CPAN! Cro::ZeroMQ (0.8.3) by 03JNTHN
New module released to CPAN! Cro::WebApp (0.8.3) by 03JNTHN
New module released to CPAN! cro (0.8.3) by 03JNTHN
New module released to CPAN! Cro::WebSocket (0.8.3) by 03JNTHN
New module released to CPAN! Cro::TLS (0.8.3) by 03JNTHN
New module released to CPAN! Cro::HTTP (0.8.3) by 03JNTHN
New module released to CPAN! Cro::Core (0.8.3) by 03JNTHN
New module released to CPAN! ValueType (0.0.2) by 03ELIZABETH
tyil seems like kicking them helps
nntp one is easy to fix by letting it die when it encounters an issue, so it'll restart itself 13:29
as for the rsync service, I'll need to take a moment to figure out a prettier way
tyil if that restarts, it does a full rsync of all modules, which is a lot of data to do fi its not strictly necessary 13:30
lizmat ack 13:36
cpan-raku New module released to CPAN! ValueType (0.0.1) by 03ELIZABETH 13:37
rypervenche How do you all normally work on your modules and test them after changes made to them? I'm currently pushing to master on a git repo and then zef installing it each time, which is not ideal. Not sure how to use a different branch, but even then, it would be nice to just be able to use the module right away. I'm guessing 'use lib "lib"' and have to be in that directory or hardcode the directory there 13:46
and just exclude it from my repo? I'm curious how others do it.
lizmat zef install . 13:56
lizmat but failing that, "use lib 'lib'" when in the repo 13:57
or other various ways of doing that, like PERL6LIB=lib ?
afk&
rypervenche Ahh, didn't realize I could zef install . I'll go with that and --force-install. 14:03
Altreus I find I'm accidentally "activating" latent behaviour when I try to debug stuff 14:04
Either I'm causing blocks on incomplete promises or, in this case, accidentally activating an Object::Delayed
Any tricks to make this easier? 14:05
I'm just using say because I'm lazy
uzl[m] rypervenche: You can use the -I flag followed by where the module is located (e.g., `raku -Ilib my-script.raku`). Alternatively, you can use RAKULIB/PERL6LIB (e.g., `RAKULIB=lib raku my-script.raku`) as lizmat suggests. This way you don't need to be installing your module after every minor change. 14:48
rypervenche Sounds good. Thanks for the advice. 14:49
uzl[m] Np! 14:52
leont m: say roundrobin([1, 2], [3, 4]); say roundrobin([1, 2]);' 15:02
evalable6 (exit code 1) 04===SORRY!04=== Er…
leont, Full output: gist.github.com/e0f4793310da9fbdf9...0b5a9598cc
leont m: say roundrobin([1, 2], [3, 4]); say roundrobin([1, 2]); 15:03
evalable6 ((1 3) (2 4))
((1 2))
leont That second result is very surprising to me
I would have expected (1), (2)
guifa leont: that NaN != NaN but NaN === NaN isn’t a bug 15:08
uzl[m] m: say roundrobin [1, 2], []
evalable6 ((1) (2))
guifa You need to use === to test that something is, well, not a number
uzl[m] leont: ^ It seems you must provide a list of lists so they can be zipped up. Even if one of them is an empty list as in this case. 15:09
guifa Because === checks for identity 15:10
== checks for value, and in that sense, it should return false: NaN can be obtained from a variety of different operations, and it’s Not Safe™ to assume the values are equal
leont uzl[m]: that doesn't make sense 15:11
I can see what it does, but why would we want it to do this? 15:12
uzl[m] leont: What I gather is that with a single list, roundrobin has nothing to zip it up with so it just returns a list containing the list itself. 15:13
guifa It’s not returning the list itself 15:19
guifa m: my @a = [1,2]; say @a.WHAT; say roundrobin(@a).WHAT 15:20
evalable6 (Array)
(Seq)
guifa m: my @a = [1,2]; say @a.WHAT; say roundrobin(@a).head.WHAT 15:21
evalable6 (Array)
(List)
guifa It gathers the first element of each iterable it’s passed, and puts it into a list. Then it grabs the second element, etc. Then it returns a Seq of lists
The idea of roundrobin is that the lists don’t need to be equal 15:22
If you do (1,2) Z (3,4,5), the 5 disappears:
m: say (1,2) Z (3,4,5)
evalable6 ((1 3) (2 4))
guifa Roundrobin takes the first elements, then the second ones, and so on. But if a value doesn’t exist at that index, it just ignores it: 15:23
m: say roundrobin (1,2,3), (10,20), (100,200,300,400)
evalable6 ((1 10 100) (2 20 200) (3 300) (400))
guifa leont uzl[m] ^^ hope that helps 15:25
leont Not really
(not to be ungrateful for your effort)
uzl[m] guifa: thanks. It cleared up some things up. 15:28
guifa Actually wait 15:30
leont’s not entirely wrong. I think this is a case of the single argument rule.
m: say roundrobin( [1,2] ); say roundrobin( [3,4], ) 15:31
evalable6 ((1 2))
((3 4))
guifa m: say roundrobin( (1,2) ); say roundrobin( (3,4), )
evalable6 ((1 2))
((3 4))
guifa nm ignore me 15:32
I actually now agree that leont found a bug. It SHOULD be ((1),(2)) and ((3),(4)) 15:34
guifa I’m fairly certain it’s a single argument rule issue that’s causing it. The definition is sub rr (+lol) and that’s getting passed onto to Rakudo::Iterable::RoundrobinIterables 15:38
guifa That means that when you do (1,2),(3,4), you get lol = first item (1,2), and second item (3,4). But if you do rr([1,2]) you get lol = first item 1, second item 2. And then RR’s behavior is correct to give first item of 1 (which is 1) and first item of 2 (which is 2) in a list, as the first item of the sequence 15:40
guifa (lol = list of lists, not the more typical ha) 15:43
Here’s a way to force it down: 15:47
m: my @a = 1,2,3; say roundrobin(@a); my @b = @a,; say roundrobin(@b)
evalable6 ((1 2 3))
(([1 2 3]))
guifa of course now it’s interpretting the array as a single scalar element. *sigh* 15:48
leont I don't think I've encountered a + sigil before…
guifa it’s a slurpy
*@a = flatten all iterables into one. **@a = don’t flatten them. +@a = same as **@a, but if there’s only one argument, then flatten it 15:50
guifa heads to $day-job 15:52
Altreus How do I call the default constructor from a subclass? Is there a super keyword? 16:19
Previously I've called the method on the parent class I want to use it from 16:21
mst Altreus: what are you trying to achieve?
why bother overriding the constructor when you have BUILD and TWEAK
Altreus I'm trying to reshape the args, because most of them are actually for constructing a property 16:22
But I did change my mind halfway through
so I will try BUILD and see if it works correctly 16:23
mst I would say 90% likelihood you wanted BUILD in that case 16:24
BUILD in raky is sort of a combination of BUILDARGS and slot population
Altreus typo or nickname? :P 16:28
mst tupo
mochan Just learning raku. I have a question. Why does the program 17:49
my $a=3;say $a while $a-- .Int
evalable6 2
1
0
mochan works and prints three numbers, while the program 17:50
my $a=3;say $a while $a--
evalable6 2
1
0
mochan loops without stopping
leont It does stop, as shown above by evalable6 17:51
mochan Sorry. Your are right. I must have made some error yesterday with a similar example. I'll try to recover it. 17:52
lizmat mochan: if you do things more declarative, it makes it harder to make mistakes 17:53
m: .say for 2...0
evalable6 2
1
0
leont Yes, more declarative code is generally a good idea 17:59
mochan I found it. my $a=3; $a.say while {--$a} 18:00
I guess the braces are wrong. But I expected the block to yield the new value of $a. Actually, $a doesn't change during the infinite iteration. 18:01
lizmat mochan: that's a postfix "while" 18:08
and a block is true when evaluated as a Bool
so your code effectively says:
my $a=3; $a.say while True
lizmat and that indeed, will only stop when you make it stop 18:09
mochan Ok. Thanks! 18:10
{ 0 }.Bool returns True, but { 0 } returns 0! 18:12
mochan (do { 0 }).Bool returns False. 18:13
jnthn Only because a block at statement level is immediately evaluated; this is not true in general. 18:13
m: my $a=3; $a.say while do {--$a}
evalable6 2
1
cfa o/ 18:32
cfa leont: ah, that signal snippet is handy; thanks 19:11
it's a shame that it's necessary though
leont I perhaps should make it a module 19:12
cfa yeah
leont (with an unless Windows around it) 19:14
Not sure yet what to call it
What does it say about me that I have 3 consecutive lines with a map in them :-p 19:20
guifa leont: that you like functional programming lol 19:31
TheAthlete Hello! 19:57
Where can I find the source code of IO:: Socket::Async
cfa github.com/rakudo/rakudo/blob/mast.../Async.pm6 19:59
TheAthlete Thanks a lot! 20:00
cfa TheAthlete: np
leont You could have asked for a simpler piece of code though 20:03
Any particular problem you're hitting? 20:04
TheAthlete There are no problems at the moment. I just want to see how the module works from the inside. 20:07
leont Much of it is actually implemented in C, hence all the nqp 20:08
cpan-raku New module released to CPAN! Gnome::Gio (0.2.0) by 03MARTIMM 21:08