🦋 Welcome to the former MAIN() IRC channel of the Raku Programming Language (raku.org). This channel has moved to Libera (irc.libera.chat #raku)
Set by lizmat on 23 May 2021.
00:27 MasterDuke left 01:02 Util_ left 01:05 yewscion joined 01:17 Doc_Holliwood left 01:21 Doc_Holliwood joined 01:22 xinming_ left 01:24 xinming_ joined 02:16 frost joined 03:03 Eddward__ joined 03:05 Eddward_ left 03:59 Util joined 04:17 cornett joined 04:32 yewscion left 05:00 Doc_Holliwood left 05:37 frost left
mykhal oh, this btw addresses my .^methods>>.gist problem 05:40
05:41 xinming_ is now known as xinming
mykhal oh not, "" is not "".HOW, good morning, where is my coffee 05:41
u: coffee 05:52
unicodable6 mykhal, Found nothing!
mykhal u: beverage 05:53
unicodable6 mykhal, U+2615 HOT BEVERAGE [So] (☕)
mykhal, U+1F9C3 BEVERAGE BOX [So] (🧃)
06:04 reportable6 joined
mykhal u: tea.*cup 06:07
unicodable6 mykhal, U+0074 LATIN SMALL LETTER T [Ll] (t)
mykhal, U+0065 LATIN SMALL LETTER E [Ll] (e)
mykhal, 8 characters in total (tea.*cup): gist.github.com/6345a7f17c2aef9162...d61bbfa966
mykhal u: tea cup 06:08
unicodable6 mykhal, U+1F375 TEACUP WITHOUT HANDLE [So] (🍵)
06:38 frost joined 06:47 ufobat__ joined 06:50 Eddward__ left 06:52 patrickb joined 06:53 squashable6 left 06:55 squashable6 joined 07:00 MasterDuke joined 07:03 ufobat_ joined 07:07 ufobat__ left 07:09 Sgeo left 07:45 frost left 07:56 abraxxa left 08:03 yewscion joined 08:11 yewscion left 08:14 abraxxa joined 08:16 Doc_Holliwood joined
Altreus kebab case :D 09:05
forgot that term 09:06
09:06 pony left 09:10 Kaipi left 09:12 Kaiepi joined 09:22 linkable6 joined 09:23 linkable6 left 09:37 frost joined 10:37 evalable6 left 10:40 evalable6 joined
Geth doc: mykhal++ created pull request #3920:
Uniname examples fix/update
10:54
10:59 sono left
Geth doc: 01f5970c1e | (Michal Bozon)++ (committed by Juan Julián Merelo Guervós) | doc/Type/Cool.pod6
Uniname examples fix/update

This fixes routine examples' excessive nested quoting; longest uniname probably from older data, current one is 6 chars longer.
11:03
11:37 patrickb left, patrickb joined 11:39 patrickb left, patrickb joined 11:41 patrickb left, patrickb joined 11:43 patrickb left, patrickb joined 11:45 patrickb left, patrickb joined 11:49 patrickb left, patrickb joined 11:51 patrickb left 11:52 patrickb joined 11:53 patrickb left 11:54 patrickb joined 11:55 patrickb left 11:56 patrickb joined 11:57 patrickb left 11:58 patrickb joined, patrickb left 12:02 reportable6 left 12:39 Altai-man left, Altai-man joined 12:47 linkable6 joined 12:57 perryprog left 12:58 avuserow left, perryprog joined 13:15 leedo_ joined 13:18 m_athias joined, discord-raku-bot left, leedo left, m_athias1 left, synthmeat left, Maylay left 13:19 Maylay joined 13:20 synthmeat joined 13:25 avuserow joined 13:41 Eddward__ joined 14:05 Doc_Holliwood left 14:25 Doc_Holliwood joined 14:39 Sgeo joined 14:48 frost left 15:15 MoC joined 15:40 melezhik joined
melezhik if someone needs an html to pdf converter, I have it on Raku - sparrowhub.io/plugin/weasyprint/0.000001 15:41
a full example form markdown to pdf would be - github.com/melezhik/cv/blob/master...to-pdf.pl6 15:42
weekly: www.reddit.com/r/rakulang/comments...wn_to_pdf/ 16:20
notable6 melezhik, Noted! (weekly)
16:23 melezhik left
mykhal m: say (1/2, "1/2", ½, "½")>>.&{ try $_.Rat } 16:25
camelia (0.5 0.5 0.5 Nil)
16:36 justsomeguy joined
mykhal I think "½".Rat should work as well, can't se related open issue, but often miss something 16:39
16:41 justsomeguy left 16:45 ufobat_ left 17:22 sono joined
Altreus I concur fwiw 17:29
It seems more astonishing that it doesn't
mykhal so I've made new github.com/rakudo/rakudo/issues/4475 : Unicode fraction strings .Rat, like "½".Rat, fail 17:38
(sorry for just complaining, not sufficient Perl/Raku/nqp hacker to fix it) 17:41
Geth doc: mustafaaydn++ created pull request #3921:
using chaining operators in comparison
doc: 1cc78fdbb0 | (Mustafa Aydın)++ (committed by Juan Julián Merelo Guervós) | doc/Language/functions.pod6
using chaining operators in comparison
17:43
linkable6 Link: docs.raku.org/language/functions
tbrowder howdy, i need help with a sorting sub for Raku's sort routine. i need to sort a list of id strings which look like decimal numbers but don't sort like them. for example, in desired sorted order <1 1.1 1.10 2 2.1 2.3 2.30>
i have tried defining a sub that compares the pieces before and after the decimal point, if any, but how do i return the correct pair as a seq? 17:44
just list the two values as a list in the correct order? or ? 17:46
Altreus m: sort(~*, <1 1.1 1.10 2 2.1 2.3 2.30>) 17:49
camelia ( no output )
Altreus oh duh
m: <1 1.1 1.10 2 2.1 2.3 2.30>.sort(~*)
camelia ( no output )
Altreus oh it's not sort-by is it
m: <1 1.1 1.10 2 2.1 2.3 2.30>.sort({ $^a cmp $^b }) 17:50
camelia ( no output )
Altreus m: say <1 1.1 1.10 2 2.1 2.3 2.30>.sort({ $^a cmp $^b })
camelia (1 1.1 1.10 2 2.1 2.3 2.30)
Altreus ok thanks brain
tbrowder: I got there in the end but that appears to be just string sort
tbrowder duh, i didn't try cmp!! thnx 17:52
Altreus :) fresh eyes 17:53
tbrowder nope, i didn't give a good example (unless my eyes are bad) 17:59
m: say <1.10 1.1>.sort({$^a cmp ^$b})) 18:00
camelia 5===SORRY!5=== Error while compiling <tmp>
Variable '$b' is not declared
at <tmp>:1
------> 3say <1.10 1.1>.sort({$^a cmp ^7⏏5$b}))
tbrowder m: say <1.10 1.1>.sort({$^a cmp $^b}) 18:01
camelia (1.1 1.10)
tbrowder hm? 18:02
ok, once more... 18:03
18:04 reportable6 joined
tbrowder m: say <4.3 4.10>.sort({$^a cmp $^b}) 18:04
camelia (4.10 4.3)
tbrowder i want 4.3, 4.10 as the order 18:05
Altreus ah, because 3 < 10
tbrowder yes, so i need a sort sub to first compare the integer, then the decimal, if any 18:06
so how should i arrange the result to return after the parts are considered?
Altreus say <4.3 4.10>.sort({$^a.Int <=> $^b.Int || ($^a - $^a.Int) <=> ($^b - $^b.Int) }) 18:07
evalable6 (4.10 4.3)
Altreus er
I fully expected that to work
tbrowder i think yr close
Altreus m: say { $^a - $^a.Int }(4.3) 18:08
camelia 0.3
Altreus m: say { ($^a - $^a.Int) <=> ($^b - $^b.Int) }(4.10, 4.3)
camelia Less
Altreus oh
it's not -1, 0, 1
m say so 4 <=> 4
m: say so 4 <=> 4
camelia False
Altreus m: say so 4 <=> 5 18:09
camelia True
Altreus m: say so 4 <=> 3
camelia True
tbrowder use cmp?
on the pieces
Altreus say <4.3 4.10>.sort({ ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) })
evalable6 (4.10 4.3)
Altreus hein, it should be equivalent at this point
m: say { ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) }(4.3, 4.10)
camelia More
Altreus that's correct :/ 18:10
4.10 is more
m: say { ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) }(<4.3 4.10>)
camelia Too few positionals passed; expected 2 arguments but got 1
in block <unit> at <tmp> line 1
Altreus heh
tbrowder use ternary operator?
Altreus m: say { ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) }(|<4.3 4.10>)
camelia More
Altreus but the sub is correct :\ 18:11
that's the right answer!
but sort is doing it backwards
m: say { ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) }(|<4.10 4.3>)
camelia Less
MasterDuke just stick a .reverse on the end
or put the $^b first 18:12
Altreus but the sub is correct
Why is sort reversing it in the first place?
m: sub weirdsort { ($^a.Int <=> $^b.Int) || ($^a - $^a.Int) <=> ($^b - $^b.Int) }; say <1 1.10 1.1 1.2 1.3 1.30>.sort(&weirdsort) 18:13
camelia (1 1.10 1.1 1.2 1.3 1.30)
Altreus m: sub weirdsort { $^a.Int == $^b.Int ?? ($^a - $^a.Int) <=> ($^b - $^b.Int) !! $^a.Int <=> $^b.Int }; say <1 1.10 1.1 1.2 1.3 1.30>.sort(&weirdsort) 18:14
camelia (1 1.10 1.1 1.2 1.3 1.30)
Altreus ok I'm hooked, time to debug offline
ohhh 18:15
idiot
$^a - $^a.Int is not remotely useful :D
tbrowder ;-D that's why i need a complex example in the docs!
util helped, but still not complex enough 18:16
Altreus m: sub weirdsort { ($^a.Int <=> $^b.Int) || (S/ .+ '.' // given $^a) <=> (S/ .+ '.' // given $^b) }; say <1 1.10 1.1 1.2 1.3 1.30>.sort(&weirdsort)
camelia (1 1.1 1.2 1.3 1.10 1.30)
Altreus I was still comparing 0.3 and 0.10
instead of 3 and 10 18:17
so yeah you do have to cut it up cos there's no sensible mathematical thing that means "turn the part after the radix point into an integer of arbitrary magnitude" :D
tbrowder ok, so if i do that in my own simple way, how do i, in the sub, delare that one of the two is greater than the other for the return value? 18:19
*declare
Altreus I suppose you just do return More; return Less; return Same; 18:20
m: say 4 <=> 4
camelia Same
Altreus Referring to $^b
so you'd say More if $^b is bigger 18:21
tbrowder i'll try that, thnx!
this is all bringing back old c++ memory, i should have looked more closely at the cmp operator in docs 18:22
(or perl memory) 18:23
Altreus yeah mostly perl tricks here 18:32
the || trick in a sort is very useful
to stack up sub-groups
mykhal tbrowder , Altreus : weird, but looks like version numbers 18:48
m: say <1 1.10 1.1 1.2 1.3 1.30>>>.Version.sort
camelia (v1 v1.1 v1.2 v1.3 v1.10 v1.30)
tbrowder mykhal: thnx 18:49
MasterDuke m: say <1 1.10 1.1 1.2 1.3 1.30>.sort(*.Version) 18:50
camelia (1 1.1 1.2 1.3 1.10 1.30)
mykhal nice. btw, also GNU sort can do this, with -V 18:55
19:04 linkable6 left, evalable6 left, evalable6 joined 19:07 linkable6 joined 19:20 MoC left 20:10 RandalSchwartz joined 20:11 RandalSchwartz left 20:13 RandalSchwartz joined 20:15 thundergnat joined
thundergnat m: use lib ‘data/all-modules/github/thundergnat/Sort-Naturally’; use Sort::Naturally; say <1 1.1 1.10 2 2.1 2.3 2.30 4.3 4.10>.sort(&naturally); 20:16
camelia 5===SORRY!5=== Error while compiling <tmp>
Could not find Sort::Naturally in:
file#/home/camelia/data/all-modules/github/thundergnat/Sort-Naturally
inst#/home/camelia/.raku
inst#/home/camelia/rakudo-m-inst-2/share/perl6/site
thundergnat bummer
locally: (1 1.1 1.10 2 2.1 2.3 2.30 4.3 4.10) 20:17
Geth doc: 0429a0b0fe | Coke++ | xt/pws/code.pws
new word

from unicode char name
20:18
20:26 Manifest0 joined
tbrowder mykhal: excellent observation! 20:41
enabling MasterDuke to win the golfing prize me thinks
i did manage to get a fairly small sub using split, defined, <=>, and the ternary operator, but you folks (esp. mykhal and MasterDuke) really know Raku. THANKS 20:48
20:57 Kaiepi left 20:59 melezhik joined 21:00 Kaiepi joined
melezhik how can I create a class with a following constructor: `my $a = Foo.new(1)` ? 21:00
m: class Node { submethod BUILD (Int $data) }; Node.new(1) 21:01
camelia 5===SORRY!5=== Error while compiling <tmp>
Missing block
at <tmp>:1
------> 3ass Node { submethod BUILD (Int $data) 7⏏5}; Node.new(1)
moon-child that's an unfortunate truncation
melezhik m: class Node { submethod BUILD (Int $data) { ... } }; Node.new(1)
camelia Default constructor for 'Node' only takes named arguments
in block <unit> at <tmp> line 1
melezhik `«Default constructor for 'Node' only takes named arguments` basically I need to change this ... 21:02
MasterDuke create your own new?
melezhik m: class Node { submethod new (Int $data) { ... } }; Node.new(1) 21:03
camelia Stub code executed
in submethod new at <tmp> line 1
in block <unit> at <tmp> line 1
melezhik m: class Node { has $.data; submethod new (Int $data) { $!.data = data } }; Node.new(1)
camelia 5===SORRY!5=== Error while compiling <tmp>
Undeclared routine:
data used at line 1
melezhik m: class Node { has $.data; submethod new (Int $data) { $!.data = $data } }; Node.new(1) 21:04
camelia Cannot modify an immutable Str (Nil)
in submethod new at <tmp> line 1
in block <unit> at <tmp> line 1
melezhik m: class Node { has Int $.data; submethod new (Int $data) { $!.data = $data } }; Node.new(1)
camelia Cannot modify an immutable Str (Nil)
in submethod new at <tmp> line 1
in block <unit> at <tmp> line 1
melezhik now I stuck with that ... 21:05
moon-child m: class Node { has Int $.data; submethod new (Int $data) { self.bless(:$data) } }; say Node.new(1)
camelia Node.new(data => 1)
melezhik m: class Node { has Int $.data; submethod new (Int $d) { $!.data = $d } }; Node.new(1) 21:07
camelia Cannot modify an immutable Str (Nil)
in submethod new at <tmp> line 1
in block <unit> at <tmp> line 1
melezhik why can't I change $.data?
moon-child I guess you need to make both your own new and BLESS 21:10
m: class Node { has Int $.data; submethod new (Int $data) { self.bless(:$data) }; submethod BUILD(Int :$data) { $!data = $data } }; say Node.new(1)
camelia Node.new(data => 1)
melezhik sigh ... seems not intuitive to me ... what the difference between redefining new and BUILD and why should redefine both? 21:11
brb 21:12
moon-child my understanding is, new is called with a type object self, BUILD is called with an actual newly instantiated object
21:12 Kaiepi left
moon-child and bless is what creates the new object and then calls BUILD 21:13
21:20 thundergnat left
melezhik moon-child thanks for clarification 21:24
mykhal is somewhat shy to accept some tbrowder's compliments.. what looks like really knowing Raku might just be recently read certain doc chapters 21:25
melezhik m: class Node { has Int $.data; has Str $.foo; submethod new (Int $data) { self.bless(:$data) } }; Node.new(1) 21:27
camelia ( no output )
melezhik m: class Node { has Int $.data; has Str $.foo; submethod new (Int $data) { self.bless(:$data) } }; say Node.new(1)
camelia Node.new(data => 1, foo => Str)
melezhik moon-child looks like we don't even need to redefine BUILD. the only magic is that new's parameter should be named after class data 21:28
so it should be `submethod new (Int $data) { self.bless(:$data) } ` 21:29
not something `submethod new (Int $d) { self.bless(:$d) }`
m: class Node { has Int $.data; has Str $.foo; submethod new (Int $data) { self.bless(:$data) } }; Node.new(1).foo = "OK" 21:31
camelia Cannot modify an immutable 'Str' type object
in block <unit> at <tmp> line 1
melezhik I also stuck here
why can't I modify foo?
raydiak attributes default to read-only. you need 'is rw' after 'has Str $.foo' 21:33
melezhik oh, thanks
raydiak yw
melezhik I even at some point remember that )))
have not touched Raku classed in awhile ... 21:34
classes
raydiak it's a very broad language, there's a lot to remember/forget :) 21:35
melezhik raydiak absolutely, I always feel like that! 21:40
21:41 Kaiepi joined
raydiak it's not entirely unintentional. aspects of the design were modeled after natural human languages, including the idea that there is a lot of vocabulary and most people don't know and retain all of it, just the parts they frequently read/write/hear/say. one of the reasons we have several ways of doing most things 21:43
I can't even remember all of just the operators and I started with raku in 2013 :D 21:45
melezhik yeah, makes a sense 21:46
mykhal m: say <a b>.map(* => *.succ) # wanted (a => b, b => c), if can be done better way, still wanna know if currying asterisk can be reused 22:13
camelia (a => c)
japhb mykhal: Two asterisks are going to make map pull two args per iteration. In this case, it's equal length to use $_: 22:15
m: say <a b>.map($_ => .succ)
camelia No such method 'succ' for invocant of type 'Any'. Did you mean 'sum'?
in block <unit> at <tmp> line 1
japhb m: say <a b>.map({$_ => .succ})
camelia (a => b b => c)
japhb Sorry, forgot that I'd have to add {}
mykhal yeah, i hoped for block-less. and, have to do additional .Hash to get {a => b, b => c}, which I in fact wanted rather :) 22:18
moon-child my @x = <a b>; my %x; %x{@x} = @x».succ; say %x 22:21
evalable6 {a => b, b => c}
japhb Do we have any other tree structure serialization format codecs in the ecosystem other than JSON, BSON, CBOR, YAML, and .raku? I'm not including CSV because it's for tabular instead of tree-structured data, and I didn't see any XML libraries that looked like they could take an arbitrary tree of Raku data and encode into XML with a single call. 22:22
(Though of course I could have missed one.)
moon-child toml?
(though I would not use toml for nested data)
japhb moon-child: Hmmm, I've never used toml. Why do you say it would *work* for nested data but you wouldn't use it for that? 22:24
moon-child just, the format is not really suited to that 22:25
toml is essentially a formalization of ini; it's intended for simple config files
japhb Ah, gotcha 22:41
22:41 evalable6 left, linkable6 left
japhb I'm discovering that our various serialization modules have *wildly* different performance profiles. To a frustrating degree when doing performance tests, actually, because I can't reasonably use the same test data for some of them, let alone the same iteration count. 22:43
Also it seems to be too easy to make grammars with really poor performance behavior, likely quadratic or worse. 22:47
22:50 Doc_Holliwood left
mykhal m: say (<a b>.map({:$_}), <a b>.map({:$^a})) # :-o 23:10
camelia ((_ => a _ => b) (a => a a => b))
moon-child yeah, :$x means x => $x 23:13
mykhal m: say (<a b>.map({:$^xxx})
camelia 5===SORRY!5=== Error while compiling <tmp>
Unable to parse expression in parenthesized expression; couldn't find final ')' (corresponding starter was at line 1)
at <tmp>:1
------> 3say (<a b>.map({:$^xxx})7⏏5<EOL>
expecting any o…
moon-child where the lhs of the => ignores any symbols and twigils
mykhal interesting 23:14
moon-child err, sigils and twigils
mykhal well, still might not get it, is it related to e.g. ... ? 23:19
m: say :3days
camelia Unexpected named argument 'days' passed
in block <unit> at <tmp> line 1
mykhal m: say ( :3days )
camelia days => 3
mykhal or is it mentioned in docs.raku.org/type/Pair ?
maybe sleep and morning helps 23:20
seems related but 23:21
oooh. ok. night 23:22
btw, it does not feel right, if _ in $_ is supposed to mean nothing 23:23
23:26 Doc_Holliwood joined 23:30 squashable6 left 23:31 squashable6 joined