🦋 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.
canw How to read password from keyword not displaying it in Raku? 03:04
Util m:say <1 1.1 1.10 2 2.1 2.3 2.30>.sort({ .comb(/\d+/)».Int }); 03:55
m: say <1 1.1 1.10 2 2.1 2.3 2.30>.sort({ .comb(/\d+/)».Int }); 03:56
camelia (1 1.1 1.10 2 2.1 2.3 2.30)
Util tbrowder: Is this what you wanted? ^^^
It is from rosettacode.org/wiki/Sort_a_list_of...fiers#Raku (which can have multiple dots), 03:57
and works because when Raku compares two lists, it compares first elements, then goes to 2nd elements only if 1st were a tie, etc.
So, making Numerics into lists of 1 or 2 elements (depending on pure-Int vs has-a-frac-part) works,
provided we turn all the .comb'ed bits back into numbers with hyper .Int.
mykhal Util: nice. also behaves the same like version sort for debatable cases like -2, 1.04 07:25
MasterDuke canw: you'll have to use something like modules.raku.org/dist/Terminal::Re...ub:titsuki or modules.raku.org/dist/Terminal::Ge...an:TITSUKI 07:30
tellable6 MasterDuke, I'll pass your message to canw
mykhal moon-child: ok, these :$_ 's are mentioned at least in docs.raku.org/language/operators#term_{_} , not very explicit though 07:56
raydiak pair forms (including :$) are also covered or mentioned in docs.raku.org/type/Pair docs.raku.org/language/syntax#Adve...lon_pairs) docs.raku.org/language/glossary#Co...colon_list docs.raku.org/language/glossary#Adverbial_pair docs.raku.org/type/Signature#Posit..._arguments and docs.raku.org/type/Capture 08:47
mykhal raydiak: tanks. i was adressing special case with $_ , where i feel _ is not supposed to me exactly "name" 08:51
.. s/me/be/ 08:52
raydiak gotcha. it's just another variable, works the same way as usual :$whatever 08:52
mykhal m: say :$ # .. i have spotted even standalone $ 08:56
camelia 5===SORRY!5===
Argument to "say" seems to be malformed
at <tmp>:1
------> 3say7⏏5 :$ # .. i have spotted even standalone
Confused
at <tmp>:1
------> 3say :$7⏏5 # .. i have spotted even standalone $
expecting any of:…
mykhal m: say :($)
camelia ($)
raydiak that's a placeholder. it truly has no name 08:57
lizmat it's also the nameless state variable
m: sub a() { say $++ }; a for ^10 08:58
camelia 0
1
2
3
4
5
6
7
8
9
raydiak that's cool, I didn't know that worked 08:59
I've written (state $)++ to do that in the past 09:02
mykhal m: say ( ++$ for ^5 )
camelia (1 2 3 4 5)
mykhal m: say ( -$ for ^5 )
camelia Use of uninitialized value of type Any in numeric context
(0 0 0 0 0)
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context
in block at <tmp> line 1
Use of uninitialized value of type Any in numeric context…
raydiak m: say $ += $++ for ^5 # triangular numbers 09:13
camelia 0
1
3
6
10
raydiak kinda fun, even if it is a bit illegible 09:14
Altreus I just discovered that sort is sort-by if the sub has chirality of 1 09:15
Signatures make so much magic possible! 09:16
mykhal m: say ( !$ for ^2 ) # ??
camelia (True True)
Altreus oh I missed that someone actually exemplified it in here so actually I didn't need to discover it 09:17
mykhal Altreus: i wonder what chitality means in this non-geometry, non-physics, non-chemistry context ...
moon-child arity, probably
mykhal :) 09:17
Altreus arity yes 09:21
I knew it was one of those
chirality ... arity ... charity ... something like that
Anyway, a language that easily supports different options for the same procedure really speaks to me after more than a decade of perl5 09:22
mykhal Altreus: ok, i now get that you were probably referring to Util's sort post 09:32
(with unwanted language associations) 09:33
m: say !(Any) 09:37
camelia True
mykhal m: say +(Any)
camelia Use of uninitialized value of type Any in numeric context
0
in block <unit> at <tmp> line 1
mykhal m: say +() 09:51
camelia 0
Altreus a sort post? 10:18
mykhal Altreus: a post on sorting, or, just a post (or multiple consecutive ones), there are no other posts of him/her in a couple of days 10:25
m: say (0+0, [+], 0 gcd 0) 10:27
camelia (0 0 0)
mykhal m: say ( [gcd], )
camelia No zero-arg meaning for infix:<gcd>
in block <unit> at <tmp> line 1
Altreus I was referring to the discussion in which you pointed out we were sorting things like version numbers 10:29
i.e. you can just pass *.Version to sort and it will DTRT 10:30
probably some sort of schwartzian thing 10:31
MasterDuke yeah, it'll do a schwartzian transform for that case
mykhal Altreus: ah, ok. but there, variadicity is no as obvious as in Util's .sort({ .comb/\d+/>>.Int }) 10:33
.. plus parens around regexp 10:34
melezhik . 14:20
Altreus ; 14:49
mykhal m: say <,> 15:04
camelia ,
mykhal m: say { $_ ?? &?BLOCK($_-1) * $_ !! 1 }(10) 16:03
camelia 3628800
mykhal fignting with Match object, getting an excessive space somehow, minimal example: 18:56
say: "x12x3".subst(:g, /['x'(\d+)]+/, { $/.caps>>.value })
m: say "x12x3".subst(:g, /['x'(\d+)]+/, { $/.caps>>.value }).raku
camelia "12 3"
mykhal .. i need that [...]+ s better example would be this (and expected result is "0zzz123" : 19:00
m: say "x0zzzx12x3".subst(:g, /['x'(\d+)]+/, { $/.caps.grep(*.key == 0)>>.value }).raku 19:01
camelia "0zzz12 3"
mykhal this Match object is somewhat chunky 19:02
moon-child m: say S:g/'x' (\d+)/$0/ given 'x0zzzx12x3' 19:04
camelia 0zzz123
mykhal nice, however I want to beat this { $/ } code solution 19:05
moritz don't use the outer + in your subsitution regex
moon-child mykhal: then 19:06
say "x0zzzx12x3".subst(:g, /['x'(\d+)]+/, { $/.caps.grep(*.key == 0)>>.value.join }).raku
moritz the problem is that that $/.caps>>.value returns a list of two values, because the + made it match twice
moon-child m: say "x0zzzx12x3".subst(:g, /['x'(\d+)]+/, { $/.caps.grep(*.key == 0)>>.value.join }).raku
camelia "0zzz123"
moritz and subst wants a string, so it joins the two values, which defaults to inserting a space
m: say ~<a bc>
camelia a bc
moritz or you can use $/.caps>>.value.join('') 19:07
that should also get rid of that space
moon-child no need for (''), can just use .join as in my example above 19:08
moritz aye, but it makes the difference less obvious
moon-child ne, fair enough
mykhal moon-child, moon-child : thanks, i was panicking of seeing miltiple "0" keys in hash 19:11
during debugging
or maybe in list of pairs 19:12
i think i will continue using perl -pe / -ne for quick text filtering and processing, for some time :) 19:16
moon-child startup time has gotten better, but is still a reason to prefer perl over raku for those sorts of pipelines 19:22
e.g. over 100 runs I get perl -e exit is 66x faster than raku -e exit
mykhal did you try jvm instead of m ? :) 19:24
moon-child no 19:27
I don't even build jvm rakudo anymore; it takes forever to build and doesn't work properly
ugexe i built it on a raspberry pi 2 running net-bsd like 8 years ago... it took like 4 days 19:29
mykhal but perl then might be even 666x faster
i tries on js, but failed, and it's not even listed in raku.org/compilers 19:31
moon-child yeah js requires a really old version of node 19:33
mykhal moon-child, moritz: reason for such complicated regex was, taht I was "hot-fixing" note entirely correct Rosettacode URL decoding example. It's already added as improved variant. rosettacode.org/wiki/URL_decoding#Raku 19:55
i guess it can be yet simpler 19:56
moon-child that red code snippet seems somewhat suspect 20:31
I might as easily say 'use URI::Encode; uri_decode whatever'
mykhal you mean red $url string? these are from test cases at page top 20:33
but agree, for comparison, that Red (lang) example below is too short. 20:35
i saw it forst time while ago and saw it's wrong for multibyte char. 20:36
moon-child: oh you meant Red :) 21:06
moon-child yes 21:07
mykhal well, not only Raku has strangely named functions (like take for yield), here Red has dehex which does nothing with "deadbeef", but un-urlquotes 21:10
japhb Naming is hard, let's do quantum physics instead. 21:14
mykhal m: say "".^method_names.grep: /hex/ 21:15
camelia ()
moritz m: say 255.base(16) 21:16
camelia FF
moritz m: say :16('FF')
camelia 255
moon-child gather/take is from mathematica
moritz somehow I am reminded of a quote in one of my favorite books, "Those that yield are not always weak" 21:17
moon-child (or, at least, it also appears in mathematica. I don't know if that's where it originates, nor if it's where raku got the names) 21:17
mykhal so Raku is not always weak as well, can yield too according to doc, I meant Python's yield 21:24
mykhal moon-child: i meat hex as in (un)hexlify, i see it can be dobe with experimental pack 21:39
mykhal m: use experimental :pack; say pack("H*", "01cafe").contents 21:47
camelia (1 202 254)
mykhal m: say "01cafe".comb(2)>>.parse-base(16) 21:58
camelia (1 202 254)
moon-child m: say 5.base('camel') 22:01
camelia 🐫🐪🐫
mykhal nice eggs 22:19
m: say 4.base("beer") 22:22
camelia 🍻🍺🍺
codesections . 22:40
tellable6 2021-06-27T01:32:36Z #raku <avuserow> codesections yeah, that only tends to be an issue when I'm subscripting without an intermediate variable, like `for %a<b>.keys {}` vs `my %b := %a<b>; for %b.keys {}`
mykhal moon-child: but i will need some emo terminal, changing from urxvt to termite isn't enough to see these (had to map uninames or copy to firefox data:text/html,<html contenteditable> ) 22:50