🦋 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.
jdv79 is it correct that Z seems to stop at a type obj? 02:19
poohman hello all 02:21
jdv79 nm
poohman is there any way to use the tail of the list in a map function 02:22
?
krako Hi everyone ! I'm new to the perl community and downloaded raku installers from rakudo. I downloaded also the *.asc files but I don't find the gpg keys. 02:24
Could anyone help me, please ?
rypervenche krako[m]: Someone will answer if you hang out a bit :) 03:07
krako[m] I'm using riot/matrix with bridge to irc:freenode so even if I quit, I'll don't miss the reply ! (if any !) 03:17
jdv79 m: class C { has $.a; submethod BUILD (:$!a) {} }; C.new(:a(none <d f>)).perl.say 03:20
camelia C.new(a => "f")
jdv79 what is going on there?
m: class C { has $.a; }; C.new(:a(none <d f>)).perl.say
camelia C.new(a => none("d", "f"))
krako[m] Just to introduce myself, I'm a programmer with some knowledge on Python/PHP/Go/Rust/HTML5/CSS3/JS.
I'm starting to learn perl (named raku now?) mainly to do text processing. I know how to use awk/grep/sed but I'm feeling quite limited with their regex capabilities
jdv79 perl and raku are related but not the same thing 03:21
raku is formerly perl6
krako[m] Does raku keep most of its syntax from perl 5 ?
jdv79 its similar enough to be related but dissimilar enough to not be called perl6;) 03:22
you could look at rosettacode maybe to see some examples side by side 03:23
i'm not super clear how that BUILD somehow transforms a junction into a string of the last element 03:24
and by not super clear i mean clueless
krako[m] Oh, I see ! Quite honestly, I don't know what to use between Perl 5 (exists on most OS) and raku, as I'm planning to use a subset of their capabilities (mostly for little scripts or on command lines). 03:29
More precisely, I'll use perl 5 or raku to avoid limitation of grep/sed/awk but not for large programming tasks as I already know other languages
jdv79 perl is mature, well known, has more modules, better regex perf... raku is newer, regex perf is not great yet, (pre)compilation times can be significant. depends on what you're looking for. 03:33
krako[m] I plan to use perl5/raku for text processing : the first project is to build a converter that will converta data from file with a specific syntax and without documentation to config files like json or yaml 03:41
krako[m] jdv79: With the "birth" of raku, do you know if perl 5 dissapear ? 03:43
jdv79 its not an easy answer:) raku grammars are very nice but kinda slow. perl is quite good at text...
krako[m] *will disappear
jdv79 nope
krako[m] nope, you don't know or nope, it won't disappear ? (sorry for insisting) 03:44
jdv79 both are mostly independently developed
though perl6 was originally thought as a possible successor those days are over 03:45
[Coke] It's a related language, it's not a replacement. 03:51
krako[m] Ok, I think for now, I'll use Perl 5 due to its maturity and availability by default on most OS. 03:56
Thank jdv79 and [Coke] for your replies !
jdv79 have fun 03:57
krako[m] (sarcastic ?) 03:58
jdv79 no. i use both almost every day:) 04:05
poohman krako: if you have the time, I suggest you give both perl and raku a try 04:13
just to ensure you base your decision on your feel for the language 04:14
jdv79 m: class C { has $.a; submethod BUILD (:$!a) {} }; C.new(:a(none <d f>)).perl.say 04:16
camelia C.new(a => "f")
jdv79 m: class C { has $.a; submethod BUILD () {$!a = %_<a>;} }; C.new(:a(none <d f>)).perl.say
camelia C.new(a => none("d", "f"))
krako[m] poohman: I think I'll start with perl 5 and then give raku a chance later .
I'm a big fan of regexes and text processing tool so, why not !
jdv79 why is that necessary?... 04:17
jdv79 krako[m]: #perl is the other chan 04:18
krako[m] <jdv79 "why is that necessary?..."> I'll test raku because I'm curious about things that use regexps and allow me to do text processing. So, mostly curiosity ! 04:28
mst krako[m]: perl5 is cool and my usual tool 04:29
mst krako[m]: raku grammars are *very* much worth looking at 04:29
krako[m] noted ! 04:31
AlexDaniel` krako: I think you'll need to try both to actually see what each one excels at in your particular tasks 04:40
perl5 is great, fast and reliable, but very often I'm willing to sacrifice a bit of that for something that is more enjoyable to write 😇 04:42
AlexDaniel` but you can probably tell by my avatar that I'm biased 😁 04:43
krako[m] I'll do test them both 04:51
poohman m:my @a = [0..20]; @a.map(*.say) 05:45
evalable6 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
poohman is there a way to pass the tail of the array (by tail I mean the remaining array) to map or is there some other function other than map which works on lists 05:47
poohman so basically want 0 and 1..20, 1 and 2..20, 2 and 3..20 etc 05:48
or atleast is there a way to get the index in the map function - so that I can get the use the tail function and the index to get the required array 05:50
m:my @a = [0..20]; @a.map: -> $a,$b {say $a~"--"~$b} 05:55
evalable6 (exit code 1) 0--1
Too few positionals passed; expected 2 arguments but got 1
in block <unit> at /tmp/ajT7zmf7Q0 line 1

2--3
4--5
6--7
8--9
10--11
12--13
14--15
16--17
18--19
poohman m:my @a = [0..20]; @a.kv.map: -> $a,$b {say $a~"--"~$b} 05:56
evalable6 0--0
1--1
2--2
3--3
4--4
5--5
6--6
7--7
8--8
9--9
10--10
11--11
12--12
13--13
14--14
15--15
16--16
17--17
18--18
19--19
20--20
poohman m:my @a = [0..20]; @a.kv.map: -> $a,$b {say $a~"--"~@a.tail(@a.elems-$a-1)} 05:58
evalable6 0--1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18…
poohman, Full output: gist.github.com/dc8311d051862d2c74...52a80f26ec
AlexDaniel poohman: sorry, I don't understand the question. Do you need .tail? or maybe .rotor? 06:23
my @a = [0..20]; say @a.rotor(1, *) 06:24
evalable6 ((0) (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20))
AlexDaniel my @a = [0..20]; say @a.rotor(5, *)
evalable6 ((0 1 2 3 4) (5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20))
poohman AlexDaniel: I looked into rotor but could not do what I wanted to do with it 06:26
poohman I need to traverse the array and then for each element need the remaining array 06:27
AlexDaniel ah 06:28
poohman m:my @a = [0..20]; @a.kv.map: -> $a,$b {say $a~"--"~@a.tail(@a.elems-$a-1)}
evalable6 0--1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18…
poohman, Full output: gist.github.com/09d3300bb3c2765ec0...58e3a72920
poohman something like this
is there a more elegant solution? 06:29
AlexDaniel e: my @a = [0..20]; for 1..^@a { my ($, $elem, @rest) = @a.rotor($_, 1, *); say $elem; say @rest } 06:30
evalable6 (1)
[(2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 1…
AlexDaniel, Full output: gist.github.com/6f074f6c987243083a...3b37a4bdbd
AlexDaniel hmm that's pretty close isn't it 06:31
lizmat: I think rotor is wrong to deny requests for 0 elements 06:33
poohman let me try to go over ur solution in my repl
AlexDaniel lizmat: here:
m: say (0..20).rotor(2, 1, 5) 06:34
camelia ((0 1) (2) (3 4 5 6 7) (8 9) (10) (11 12 13 14 15) (16 17) (18))
AlexDaniel m: say (0..20).rotor(1, 1, 5)
camelia ((0) (1) (2 3 4 5 6) (7) (8) (9 10 11 12 13) (14) (15) (16 17 18 19 20))
AlexDaniel m: say (0..20).rotor(0, 1, 5)
camelia Rotorizing sublist length is out of range. Is: 0, should be in 1..^Inf;
Did you mean to specify a Pair with => 0?
in block <unit> at <tmp> line 1
AlexDaniel lizmat: for the code above it is actually a needless limitation
zero elements just means an empty list, otherwise DIHWIDT 06:35
poohman: github.com/rakudo/rakudo/issues/3588 06:50
poohman thanks AlexDaniel 06:52
AlexDaniel poohman: I'd say your solution is totally fine 06:54
my @a = [0..20]; for ^@a { say @a[$_]; say @a.tail(@a-$_-1) }
evalable6 0
(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18…
AlexDaniel, Full output: gist.github.com/ca34b8a557efc10001...7488542902
AlexDaniel poohman: you don't need .kv so you can simplify it, but otherwise the logic is simple enough 06:55
poohman perfect thanks 06:56
AlexDaniel poohman: you can also do (@a.end-$_) if you don't like -1
cpan-raku New module released to CPAN! Term::Choose::Util (1.3.4) by 03KUERBIS 08:03
tbrowder hi, #raku people, keeping social distance i hope 11:09
lizmat offline indeed :-) 11:10
tbrowder gut!
in my porting effort i have a large number of methods, some of which are exportable in perl's manner 11:11
tbrowder is there any advantage or disadvantage of having a class with fewer methods and instead using exportable subs? 11:13
jnthn is mostly working from home anyway, but did an office day yesterday, only to discover the boiler has broken, and so will probably be safely at home even more than planned... :) 11:14
tbrowder the word on tv now seems to be that masks are good even if it's clean hankerchief or scarf 11:16
jnthn Yes, wearning something to cover nose/mouth has been mandatory whenever out of one's home for about 2 weeks here now. 11:21
*wearing
Well, strictly "in public". 11:22
tadzik ah, we're just forbidden from going outside ;) 11:23
tellable6 2020-03-25T22:48:48Z #raku-dev <patrickb> tadzik: Rakubrew is (slowly) getting to the point of working reliably. What's your stance wrt rakudobrew? Should it officially be deprecated?
tadzik ah, hard questions 11:24
chloekek Time to go outside to get food. 11:27
jnthn tadzik: Allowed here only to go to work or to get groceries or other essentials. Otherwise not. 11:34
tadzik jnthn: yeah, same here. Groceries, doctors or helping others 11:35
but even then, you need to maintain a 2 meter distance from everyone – including people you live with, which is a bit bizarre
jnthn Oh, here there's an exception for people living in the same household. :) 11:36
tadzik perks of living in a first-world country ;) 11:38
jnthn At least you have the better pierogi :P 11:53
tadzik :D 12:00
El_Che hi, I hope everyone here is ok 12:01
Geth doc: Kaiepi++ created pull request #3301:
Mention :D types in the documentation for the "is required" trait
tbrowder jnthn: any opinion on subs vs methods and large classes? 12:59
[Coke] m: say "rakudo" XX "", "c" 13:00
camelia (((rakudo )) ((rakudo c)))
[Coke] m: say "rakudo" X~ "", "c"
camelia (rakudo rakudoc)
jnthn tbrowder: That's a bit of an abstract question, but in general: do they share any state? If not, there's probably no reason for them to be methods. If yes, group methods by the state they use to see if they really should be one class, or multiple classes. 13:14
(And yes, that's a huge over-simplification, and good OO is usually designed state-last...) 13:15
tbrowder i apologize for the looseness of the question, but your answer is very helpful, esp. for my immediate problem. thanks! 13:22
El_Che tbrowder: the question and answer are loosly coupled. A good thing in OO :) 13:56
tbrowder roger that! and OO so easy in raku :-D 13:58
regreg hello 14:08
does raku have builtin array operators? like matlab/octave
chloekek I’m not aware of built-in vector operators. 14:09
El_Che regreg: the built-in methods/routines are here: docs.raku.org/type/Array 14:10
regreg thanks
chloekek You can of course write them succinctly.
[Coke] wonders if an Operators::APL would get any use at all. :) 14:12
chloekek p6: my num @a = 1e0, 2e0, 3e0; my num @b = 4e0, 5e0, 6e0; say [+] @a Z* @b; # dot product
camelia 32
chloekek But they will probably not be nearly as fast as properly optimized linear algebra subprograms using vector instructions. 14:13
timotimo theoretically there's nothing keeping us from doing a fully optimized thing when Z* is used on native arrays of the same size and such 14:57
passing native arrays to C code with nativecall isn't allowed without a copy 14:58
timotimo github.com/MoarVM/MoarVM/commit/86...4b749ddac9 - one way to do it 15:00
but ideally we'd have something that can also fuse loops and such
i.e. not getting around actually emitting machine code with vector ops 15:01
timotimo dynasm does have a bunch of SSE* ops in it 15:03
but those can't be all of them?!
github.com/MoarVM/dynasm/blob/e1a6....lua#L1187 - starting here; chloekek do you happen to have experience with sse assembly instructions or i guess intrinsics? 15:06
timotimo anyone else can speak up too %) 15:07
chloekek Just write the function in C on godbolt.org and it will show you which instructions you have to use. 15:10
timotimo oh, i thought more of, does dasm lack any sse ops, maybe important ones? 15:11
but that'd also help for sure
chloekek godbolt.org/z/HhXgK3 it generates a lot of setup code to check for alignment, because vector instructions require proper alignment. 15:12
timotimo absolutely
chloekek But, we do not have to generate assembly for this directly.
We can generate a VM instruction for Z* on native arrays. 15:13
timotimo it's possible to get our arrays out of alignment as well :(
chloekek Then this VM instruction can call a C function like the one in the example.
timotimo did you see the moarvm commit i linked above? that was the idea for that 15:13
chloekek No, I did not see it. Now I do.
timotimo but really you get a load more performance by not doing full-array operations one after the other
chloekek Yeah just like that. :) 15:14
timotimo ... at least that's what i heard, i haven't actually done anything manual with vectorized ops yet
carefully not overselling my proficiency so that i don't get a "well volunteered" LOL
MasterDuke i think that ship sailed when you pushed a branch to the moarvm repo, not even an individual fork! 15:15
what's NYI on your branch? 15:17
timotimo everything :) :)
only supports 64bit sizes of individual values 15:18
a full implementation will of course have to support all sizes that we have, and all combinations, too
just add, sub, mul, div for floats gives you 4 * 2 * 2, then add, sub, mul, div_i and div_n gives 5 * 4 * 4 15:19
MasterDuke we already have some code generating tools in our various build processes... 15:23
chloekek In other news, I got raku-nix working with libraries that have Build.pm. 15:24
timotimo but if you actually want real performance, you have to fuse consecutive ops together
timotimo you know, have an implementaiton for a + b + c, one for a + b * c, a * b * c, ... 15:29
reordering lets you eliminate a couple of the formulas, of course
jdv79 anyone know why sig binding seems to break junctions?
i'm guessing it's causing iteration and ends up with the last value... 15:30
timotimo signature binding errors out when autothreading is needed, so that the caller of the signature bind can do the autothreading
if you're talking about the lowest level of the signature binder, that is 15:31
jdv79 m: class C { has $.a; submethod BUILD (:$!a) {} }; C.new(:a(none <d f>)).perl.say 15:32
camelia C.new(a => "f")
jdv79 m: class C { has $.a; submethod BUILD () {$!a = %_<a>;} }; C.new(:a(none <d f>)).perl.say
camelia C.new(a => none("d", "f"))
jdv79 why is the 2nd one necessary for the junction to survive a BUILD?
timotimo interesting
possibly a bind vs assignment difference, or something the signature lowering optimization changes 15:33
jdv79 bug or on purpose? the people want to know! :)
timotimo too headachy to dig into it right now :( 15:37
MasterDuke committable6: all class C { has $.a; submethod BUILD (:$!a) {} }; C.new(:a(none <d f>)).perl.say; class D { has $.a; submethod BUILD () {$!a = %_<a>;} }; D.new(:a(none <d f>)).perl.say 15:38
committable6 MasterDuke, ¦all (64 commits): «C.new(a => "f")␤D.new(a => none("d", "f"))␤»
MasterDuke well, not a regression at least 15:39
guifa o/ 16:18
[Coke] \o 16:30
chloekek Hmm, > This type cannot unbox to a native string: P6opaque, IO::Path 16:40
Funny bug in DBIish when it cannot find a .so 16:41
tbrowder \o\ 16:45
chloekek Bizarre that it can’t find it though, I set LD_LIBRARY_PATH correctly. 16:46
DrGuifa successfully defended his dissertation this week 16:54
phogg DrGuifa: How much XP did you get?
DrGuifa +100, but -10000000 luck because I can’t celebrate because COVID19 16:55
tobs DrGuifa: congratulations nonetheless! 16:58
DrGuifa I’m going to do a post at some point about the role of Raku in it at some point. All of my backend code is Raku, front end JavaScript because I didn’t have time to really play with the JS runtime 16:59
jnthn DrGuifa++ # look forward to reading that 17:01
And congrats :)
DrGuifa jnthn my next step is to do a Cro backend for collaborative editing 17:03
DrGuifa wrote about a medieval book and focused on digital transcriptions / editions
Raku grammars were actually pretty fundamental, even though being a humanities dissertation I didn’t really talk about them per se very much in the paper itself 17:04
cpan-raku New module released to CPAN! Gnome::Gtk3 (0.27.0.1) by 03MARTIMM
New module released to CPAN! Gnome::Gio (0.4.2) by 03MARTIMM
New module released to CPAN! Gnome::Gdk3 (0.15.4) by 03MARTIMM 17:05
New module released to CPAN! Gnome::GObject (0.16.1) by 03MARTIMM
New module released to CPAN! Gnome::Glib (0.17.0.3) by 03MARTIMM
New module released to CPAN! Gnome::N (0.17.2) by 03MARTIMM
tbrowder DrGuifa: congratulations! 17:18
DrGuifa One thing I realized I definitely need to do is create a grammars for objects 17:19
DrGuifa . o O ( and at least one person had complained about grammars not handling binary blobs either, so maybe I´ll make that summer project #9948651 ) 17:20
dakkar is one of those people wishing to match blobs with grammars 17:24
I mean, network protocols are well modeled by supplies of blobs, not strings…
DrGuifa dakkar: I think I have a good idea of how I want to do it except for allowing it to work syntactically just like regularly grammars (e.g. having the inside of the token brackets parsed under a different grammar) 17:25
DrGuifa But I think I’ll toss together a model using a standard class with methods returning string objects first, and then deal with the fancy Raku-ness of it 17:26
dakkar that sounds like a good plan 17:27
first, make it work; then, make it pretty ☺
chloekek I am most confused. 17:47
Hmm, it seems that JSON::Fast used to be in the panda repo. 17:50
chloekek Cool! I can now completely automatically generate Nix packages from Raku libraries hosted on CPAN or GitHub. :) 17:52
cpan-raku New module released to CPAN! Gnome::Gio (0.4.2.1) by 03MARTIMM 17:53
MasterDuke DrGuifaL congrats 18:07
Altreus these release things need URLs to follow 18:22
rypervenche releasable6, status 18:25
releasable6 rypervenche, Next release will happen when it's ready. 3 blockers. 166 out of 287 commits logged (⚠ 3 warnings)
rypervenche, Details: gist.github.com/0d6497bd78bb14c28e...049edfa741
jdv79 is there an overly clever way to get a series of DateTimes given endpoints and a period? 21:07
moritz jdv79: there's always the series operator 21:21
m: say (DateTime.now(2020, 1, 1, 0, 0, 0), *+3600 ... *).head(5) 21:23
camelia Too many positionals passed; expected 1 argument but got 7
in block <unit> at <tmp> line 1
moritz m: say (DateTime.new(2020, 1, 1, 0, 0, 0), *+3600 ... *).head(5)
camelia Cannot resolve caller Numeric(DateTime:D: ); none of these signatures match:
(Mu:U \v: *%_)
in block <unit> at <tmp> line 1
moritz m: say (DateTime.new(2020, 1, 1, 0, 0, 0), *+Duration.new(3600) ... *).head(5)
camelia (2020-01-01T00:00:00Z 2020-01-01T01:00:00Z 2020-01-01T02:00:00Z 2020-01-01T03:00:00Z 2020-01-01T04:00:00Z)
jdv79 moritz: neat 22:01
lizmat m: role Interval[\seconds = 3600] { my \step = Duration.new(seconds); method succ() { self + step } }; say (DateTime.new(2020,1,1,0,0,0) but Interval ... *).head(5) 22:20
camelia (2020-01-01T00:00:00Z 2020-01-01T01:00:00Z 2020-01-01T02:00:00Z 2020-01-01T03:00:00Z 2020-01-01T04:00:00Z)
Kaiepi m: gather for 1..10 { .take }.elems for ^100_000; say now - $*INIT-INSTANT 22:21
camelia 5.80473565
Kaiepi m: class Foo does Iterator { has Int:D $!i = 1; method pull-one is raw { return IterationEnd if $!i >= 10; $!i++ } }; Seq.new(Foo.new).elems for ^100_000; say now - $*INIT-INSTANT 22:22
camelia 1.4806662 22:22
Kaiepi oh damn that's a lot faster than i expected
lizmat Kaiepi: with the refactoring of ... I'm working on, I'm seeing performance improvements 4x to 15x so far 22:23
Kaiepi nice!
lizmat currently (re)writing extensive tests 22:25
and finding some off stuff 22:26
like:
m: dd 1 ... 5.5
camelia (1, 2, 3, 4, 5).Seq
lizmat m: dd 1 ...^ 5.5
camelia (1, 2, 3, 4, 5).Seq
lizmat the latter I think is incorrect
timotimo depends on how you interpret ...^ ; if it's "up to but not including the end point" it's correct, if you interpret it as "same as ... but drop the last entry" then not 23:00
oh it's ... not .. 23:02
then i think i agree