🦋 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:03 reportable6 left, Doc_Holliwood left 00:53 RandalSchwartz left 01:13 RandalSchwartz joined, RandalSchwartz left 02:13 bisectable6 left, squashable6 left, statisfiable6 left, releasable6 left, unicodable6 left, notable6 left, shareable6 left, bloatable6 left, benchable6 left, coverable6 left, committable6 left, tellable6 left, quotable6 left, greppable6 left, sourceable6 left, nativecallable6 left 02:14 bloatable6 joined 02:15 benchable6 joined, squashable6 joined, bisectable6 joined, greppable6 joined, tellable6 joined, sourceable6 joined 02:16 coverable6 joined, statisfiable6 joined, unicodable6 joined, quotable6 joined 02:26 frost joined 03:03 canw joined
canw How to read password from keyword not displaying it in Raku? 03:04
03:08 Xliff left 03:17 canw left 03:20 canw joined 03:25 frost left 03:42 nativecallable6 joined 03:50 shareable6 joined 03:52 melezhik left 03:54 frost joined
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.
04:40 evalable6 joined 04:41 canw left 04:42 canw joined 05:12 Guest9 joined 05:22 ufobat_ joined 05:28 releasable6 joined 05:56 canw left 06:03 reportable6 joined 06:17 linkable6 joined 06:23 Guest9 left 06:49 Doc_Holliwood joined 06:52 Sgeo left 06:59 Nahita joined 07:03 ufobat__ joined, committable6 joined 07:06 ufobat_ left 07:14 Eddward__ left 07:15 abraxxa left
mykhal Util: nice. also behaves the same like version sort for debatable cases like -2, 1.04 07:25
07:28 Doc_Holliwood left
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
07:39 patrickb joined
mykhal moon-child: ok, these :$_ 's are mentioned at least in docs.raku.org/language/operators#term_{_} , not very explicit though 07:56
08:39 evalable6 left, linkable6 left 08:41 linkable6 joined
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
08:52 patrickb left
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 ($)
08:56 patrickb joined
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…
09:04 Nahita left 09:09 patrickb left
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
09:17 patrickb joined
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
10:17 linkable6 left
Altreus a sort post? 10:18
10:20 linkable6 joined 10:25 sena_kun joined
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
10:51 Nahita joined 11:17 Doc_Holliwood joined 11:26 sono left 11:47 notable6 joined 12:02 reportable6 left 12:03 Doc_Holliwood left 12:20 yewscion joined, Doc_Holliwood joined 12:25 yewscion left 13:11 linkable6 left 13:33 Sgeo joined 13:53 Eddward__ joined 14:12 Doc_Holliwood left 14:20 melezhik joined
melezhik . 14:20
14:28 reportable6 joined 14:32 Doc_Holliwood joined
Altreus ; 14:49
mykhal m: say <,> 15:04
camelia ,
15:16 linkable6 joined 15:34 Doc_Holliwood left 15:54 silug left 16:00 silug joined
mykhal m: say { $_ ?? &?BLOCK($_-1) * $_ !! 1 }(10) 16:03
camelia 3628800
16:09 silug left 16:12 silug joined 16:21 Nahita left 16:45 Kaiepi left 16:51 Kaiepi joined 16:52 Kaipi joined, Kaiepi left 16:57 Kaipi left 16:58 Kaipi joined 17:01 Kaipi left 17:02 Merfont joined, Merfont left 17:03 Merfont joined 17:08 Nahita joined, Merfont left 17:10 ufobat__ left 17:11 Kaiepi joined 17:14 Kaipi joined 17:16 Kaiepi left 17:18 Kaipi left, Kaiepi joined 17:39 sena_kun left 18:02 reportable6 left 18:03 Nahita left 18:05 reportable6 joined 18:14 Nahita joined 18:19 Doc_Holliwood joined 18:25 Nahita left 18:35 archenoth joined 18:37 Oshawott left 18:38 Oshawott joined 18:40 archenoth left, Kaiepi left 18:41 Kaiepi joined
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
19:18 cooper left
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
20:12 Nahita joined, Nahita left, sono joined
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
21:12 linkable6 left
japhb Naming is hard, let's do quantum physics instead. 21:14
21:14 linkable6 joined
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
21:17 evalable6 joined
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
21:22 xkr47 left, xkr47 joined
mykhal so Raku is not always weak as well, can yield too according to doc, I meant Python's yield 21:24
21:27 Doc_Holliwood left 21:38 cognominal joined
mykhal moon-child: i meat hex as in (un)hexlify, i see it can be dobe with experimental pack 21:39
21:39 leedo joined 21:41 cognominal_ left, leedo_ left 21:46 patrickb left
mykhal m: use experimental :pack; say pack("H*", "01cafe").contents 21:47
camelia (1 202 254)
21:52 yewscion joined
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 🐫🐪🐫
22:07 yewscion left
mykhal nice eggs 22:19
m: say 4.base("beer") 22:22
camelia 🍻🍺🍺
22:31 frost left 22:39 codesections joined
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
23:22 Oshawott left 23:23 Oshawott joined