🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 6 September 2022. |
|||
01:22
skyesoss is now known as skyenet
01:32
hulk joined
01:33
kylese left
02:15
hulk left,
kylese joined
02:21
Guest38 joined
|
|||
Guest38 | hello i am a quite newbie for using raku. i have a question. is it a script language? | 02:22 | |
02:24
Guest38 left
|
|||
disbot | <jubilatious1_98524> @Guest38 Yes, Raku is a scripting language. | 03:58 | |
04:04
Aedil joined
05:46
elcaro joined
|
|||
disbot | <simon_sibl> maybe I just havent found it yet, but I wish there is or will be a way to compile Raku script so that I can easily distribute them | 06:05 | |
06:14
abraxxa joined
|
|||
disbot | <simon_sibl> using App::MoarVM::Debug how can I display whats within an object ? (a scalar in this case) | 06:24 | |
<simon_sibl> I get the handle with all lexicals but then I dont find a command to display whats actually inside | |||
<jubilatious1_98524> weekly: stackoverflow.com/a/79756465/7270649 | 06:36 | ||
notable6 | jubilatious1_98524, Noted! (weekly) | ||
disbot | <simon_sibl> in that example, I dont get the part where it keeps the right order ? | 06:41 | |
<simon_sibl> since hash keys are random order | 06:42 | ||
<simon_sibl> (also not sure to understand why.head is necessary when accessing the value) | 06:45 | ||
<jubilatious1_98524> @simon_sibl Thanks for the feedback. The hash is constructed with ++$ as value. This can be thought of as simply adding a line number as value. | 06:48 | ||
<jubilatious1_98524> Because we .push onto the hash, values accumulate. So then we can 1). sort on the first value (i.e. *.value.head), and 2). select only keys where the number of elems equals one. | 06:49 | ||
<jubilatious1_98524> (Note: this SO question isn't about de-duplicating lines within a file, it's about REMOVING all lines that appear in duplicate). | 06:50 | ||
<jubilatious1_98524> (Also, the OP asks for the output to be in INPUT order, not numeric order. Hence the use of ++$ line numbers). | 06:52 | ||
<simon_sibl> oooh | 06:54 | ||
<simon_sibl> I get it | |||
<simon_sibl> alright, I wasnt yet used to the push on hash | 06:55 | ||
<simon_sibl> quite interesting | |||
<simon_sibl> thanks for the explanation ! | |||
<simon_sibl> I am always confused with sort maybe because of how Perl does it | 06:59 | ||
<simon_sibl> in Raku, how does it know if I want alphabetical order or numeric order ? | 07:00 | ||
<simon_sibl> because in the doc it says by default it will use cmp which is for string right ? while <=> is for numeric | |||
<simon_sibl> but when I do | |||
<simon_sibl> m: (1, 4, 11, 6).sort.say | |||
evalable6 | (1 4 6 11) | ||
disbot | <Raku eval> (1 4 6 11) | ||
<simon_sibl> its the right order | |||
07:00
itaipu left
|
|||
disbot | <simon_sibl> m: <a b ac c>.sort.say | 07:01 | |
<Raku eval> (a ac b c) | |||
evalable6 | (a ac b c) | ||
disbot | <simon_sibl> here it does lexical order | ||
<jubilatious1_98524> Good question. You can numify with + or stringify with ~. | |||
<simon_sibl> indeed, but here with sorts it seems it can detect if its sorting numbers or strings, but I am not sure xD but with the two examples I just sent its what it seems | 07:04 | ||
<simon_sibl> ah yes | |||
<simon_sibl> m: (1, 11, 30, 20 205).sort.say | 07:05 | ||
evalable6 | (exit code 1) ===SORRY!=== Error while compilin… | ||
disbot | <Raku eval> Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Two terms in a row at /home/glot/main.raku:1 ------> (1, 11, 30, 20⏏ 205).sort.say expecting any of: infix infix stopper statement end statement modifier statement modifier loop | ||
evalable6 | simon_sibl, Full output: gist.github.com/8a3548e4b89390dd71...65c576fb57 | ||
disbot | <jubilatious1_98524> Here's the sorted output form the second input sample B => [1 5] A => [2 6] D => 3 C => 4 | ||
<simon_sibl> m: (1, 11, 30, 20, 205).sort.say | |||
evalable6 | (1 11 20 30 205) | ||
disbot | <Raku eval> (1 11 20 30 205) | ||
<simon_sibl> m: <1, 11, 30, 20 205>.sort.say | |||
evalable6 | (1, 11, 20 205 30,) | ||
disbot | <Raku eval> (1, 11, 20 205 30,) | ||
<simon_sibl> makes sense makes sense | |||
<simon_sibl> yep thank you ! I find your answer quite clever | 07:06 | ||
<jubilatious1_98524> ~ % raku -e '<1 11 30 20 205>.sort.say;' (1 11 20 30 205) | 07:07 | ||
<simon_sibl> what how | 07:08 | ||
<jubilatious1_98524> ~ % raku -e 'say <1 205 11 30 20 >.sort: *.Int;' (1 11 20 30 205) | 07:09 | ||
<jubilatious1_98524> ~ % raku -e 'say <1 205 11 30 20 >.sort: *.Str;' (1 11 20 205 30) | |||
<simon_sibl> but here it should be as Str by default no ? | 07:10 | ||
<simon_sibl> like here | |||
<simon_sibl> oh wait I missed a , | |||
<simon_sibl> oh no shouldnt have , | |||
<jubilatious1_98524> Yeah, don't need commas within <> | |||
<simon_sibl> m: <1 20 30 45 205>.sort.say | |||
evalable6 | (1 20 30 45 205) | ||
disbot | <Raku eval> (1 20 30 45 205) | ||
<simon_sibl> m: <1 20 d 30 aa 45 c 205 a >.sort.say | 07:11 | ||
<Raku eval> (1 20 30 45 205 a aa c d) | |||
evalable6 | (1 20 30 45 205 a aa c d) | ||
disbot | <simon_sibl> what | ||
<simon_sibl> its half numeric and half lexical sorted ? xd | |||
07:11
wayland76 joined
|
|||
disbot | <jubilatious1_98524> m: say <1 20 30 45 205>.sort: ~* | 07:12 | |
evalable6 | (1 20 205 30 45) | ||
disbot | <Raku eval> (1 20 205 30 45) | ||
<simon_sibl> but yeah all this because I was worried when sorting files by created_date and was worried it would use lexical order instead of numeric | |||
<simon_sibl> but now I know its a "smart" sort unlike in Perl5 | |||
<jubilatious1_98524> It's ASCII sort, right? numbers first, then uppercase then lowercase. | 07:14 | ||
<jubilatious1_98524> ~ % raku -e '<1 20 d 30 aa 45 c 205 a A AA >.sort.say' (1 20 30 45 205 A AA a aa c d) | |||
<jubilatious1_98524> (maybe not right term). | 07:15 | ||
<simon_sibl> Oooh looks about right | |||
<simon_sibl> But for 20 and 205 why not the same order ? | |||
<jubilatious1_98524> I guess numbers in numeric (natural sort order), then ASCII rules, which must get extended to Unicode as well. | 07:19 | ||
<jubilatious1_98524> m: say <àèéìòù>.flip.sort; | 07:21 | ||
evalable6 | (ùòìéèà) | ||
disbot | <Raku eval> (ùòìéèà) | ||
07:21
itaipu joined
|
|||
disbot | <jubilatious1_98524> m: <àèéìòù>.sort.say; | 07:22 | |
<Raku eval> (àèéìòù) | |||
evalable6 | (àèéìòù) | ||
disbot | <jubilatious1_98524> Duh, no spaces. | ||
<jubilatious1_98524> m: say <à è é ì ò ù>.flip.sort; | 07:23 | ||
evalable6 | (ù ò ì é è à) | ||
disbot | <Raku eval> (ù ò ì é è à) | ||
<simon_sibl> m: say <à è é ì ò ù>.sort | 07:25 | ||
evalable6 | (à è é ì ò ù) | ||
disbot | <Raku eval> (à è é ì ò ù) | ||
<simon_sibl> m: say <é à è ì ò ù>.sort; | |||
<Raku eval> (à è é ì ò ù) | |||
evalable6 | (à è é ì ò ù) | ||
disbot | <simon_sibl> Why the flip reverse the order ? | 07:26 | |
<jubilatious1_98524> Needs to be reverse, not flip | |||
<jubilatious1_98524> ~ % raku -e '<à è é ì ò ù>.reverse.sort.say;' (à è é ì ò ù) | |||
<jubilatious1_98524> m: <à è é ì ò ù>.reverse.sort.say; | 07:27 | ||
<Raku eval> (à è é ì ò ù) | |||
evalable6 | (à è é ì ò ù) | ||
disbot | <jubilatious1_98524> flip is a mistake, will stringify into a single string. reverse is what's necessary to keep letters independent. | ||
07:28
Sgeo left
|
|||
disbot | <jubilatious1_98524> ~ % raku -e '(<à è é ì ò ù>.lc, <à è é ì ò ù>.uc).flat.say;' (à è é ì ò ù À È É Ì Ò Ù) | 07:29 | |
<jubilatious1_98524> ~ % raku -e '(<à è é ì ò ù>.lc, <à è é ì ò ù>.uc).flat.sort.say;' (À È É Ì Ò Ù à è é ì ò ù) | 07:30 | ||
<jubilatious1_98524> Yup, uppercase before lowercase. | |||
<jubilatious1_98524> docs.raku.org/routine/sort | 07:34 | ||
<jubilatious1_98524> m: <a aa aaa aaaa>.sort: *.chars | 07:35 | ||
evalable6 | |||
disbot | <Raku eval> | ||
<jubilatious1_98524> m: say <a aa aaa aaaa>.sort: *.chars | |||
<Raku eval> (a aa aaa aaaa) | |||
evalable6 | (a aa aaa aaaa) | ||
disbot | <jubilatious1_98524> say <a aa aaa aaaa>.sort: -*.chars | ||
evalable6 | (aaaa aaa aa a) | ||
disbot | <jubilatious1_98524> m: say <a aa aaa aaaa>.sort: -*.chars | 07:36 | |
evalable6 | (aaaa aaa aa a) | ||
disbot | <Raku eval> (aaaa aaa aa a) | ||
07:45
lichtkind joined
08:20
crnlskn joined
08:31
Geth joined
|
|||
Voldenet | m: <1 20 d 30 aa 45 c 205 a A AA >.sort.say # this is using IntStr which is ridiculous for sorting | 09:43 | |
camelia | (1 20 30 45 205 A AA a aa c d) | ||
Voldenet | m: "1 20 d 30 aa 45 c 205 a A AA".split(" ").sort.say # this is using Str | 09:44 | |
camelia | (1 20 205 30 45 A AA a aa c d) | ||
Voldenet | m: <1 20 d 30 aa 45 c 205 a A AA >.map(*.Str).sort.say # also Str | ||
camelia | (1 20 205 30 45 A AA a aa c d) | ||
Voldenet | m: say <205> cmp <45> | 09:45 | |
camelia | More | ||
Voldenet | m: say "205" cmp "45" | 09:46 | |
camelia | Less | ||
Voldenet | but it's especially ridiculous when you use <> which is rare in actual code | ||
because actual code usually has input from user that's Str or Int | 09:47 | ||
10:14
crnlskn left
10:20
stanrifkin joined
|
|||
lizmat | fwiw, I've come to like: | 10:45 | |
m: dd q:w/foo 42 bar/ | |||
camelia | ("foo", "42", "bar") | ||
lizmat | as an alternative for: | ||
m: dd <foo 42 bar> | 10:46 | ||
camelia | ("foo", IntStr.new(42, "42"), "bar") | ||
Voldenet | m: dd q:w<foo 42 bar> | 10:47 | |
camelia | ("foo", "42", "bar") | ||
lizmat | in the latter case < > are just interpreted as delimiters without special meaning | 11:04 | |
11:29
apac joined
11:31
wayland joined
11:32
wayland76 left
|
|||
disbot | <antononcube> Ha -- 620+ views, but some down-votes too. And I am curious why... 🙂 | 13:14 | |
<antononcube> cdn.discordapp.com/attachments/633...82d9d& | |||
13:35
Geth left,
Geth joined
13:45
crnlskn joined
13:53
lichtkind left
|
|||
disbot | <jubilatious1_98524> @Voldenet but you can sort on two criteria, so IntStr isn't so bad. | 14:00 | |
<jubilatious1_98524> m: say <a bb aaa cccc>.sort({ .chars, .Str}) | 14:02 | ||
<Raku eval> (a bb aaa cccc) | |||
evalable6 | (a bb aaa cccc) | ||
disbot | <jubilatious1_98524> m: say <a cccc bb 42 aaa 1>.sort({ .chars, .Str}) | 14:03 | |
evalable6 | (1 a 42 bb aaa cccc) | ||
disbot | <Raku eval> (1 a 42 bb aaa cccc) | ||
<jubilatious1_98524> m: say <a bb aaa cccc>.sort({ .chars, .Int}) | 14:04 | ||
evalable6 | (a bb aaa cccc) | ||
disbot | <Raku eval> (a bb aaa cccc) | ||
<jubilatious1_98524> m: say <a cccc bb 42 aaa 1>.sort({ .chars, .Int}) | 14:05 | ||
<Raku eval> Exit code: 1 Cannot convert string to number: base-10 number must begin with valid digits or '.' in '⏏bb' (indicated by ⏏) in block <unit> at main.raku line 1 | |||
evalable6 | (exit code 1) Cannot convert string to number: base-10 number must begin with valid digits or '.' in '<HERE>bb' (indicated by <HERE>) in block <unit> at /tmp/ey6CRDMfK2 line 1 |
||
14:08
Sgeo joined
14:14
crnlskn left,
crnlskn joined
15:10
human-blip left
15:12
human-blip joined
15:19
human-blip left
15:21
human-blip joined
15:34
human-blip left
15:36
human-blip joined
15:37
crnlskn left
|
|||
Voldenet | jubilatious1_98524: it can be used that way, but sorting on .Str will allocate a list with strings, sort that list and then construct sorted list of allomorphs - it has to work that way because you're sorting different objects that way | 15:49 | |
you preserve .Int that way though | |||
15:51
sorenson left
15:52
apac left
15:54
sorenson joined
16:23
abraxxa left
17:08
apac joined
17:14
Geth left
17:15
Geth joined
|
|||
lizmat | PSA: the Raku IRC logs server is down because of some unexpected maint work :-( | 17:26 | |
logging is still running, so no discussions should be lost | |||
17:40
Geth left,
Geth joined
|
|||
lizmat | PSA: IRC logs servers is up again | 18:00 | |
18:17
apac left
18:46
crnlskn joined
18:47
ACfromTX left
19:03
ACfromTX joined
19:51
crnlskn left
19:52
itaipu left
20:05
apac joined
20:08
itaipu joined
20:15
crnlskn joined
20:39
Aedil left
20:49
crnlskn left
21:02
kst joined
21:55
phogg left
21:56
phogg joined
22:37
apac left
|
|||
lizmat | PSA: the IRC log server continues to hang... will need to look more in depth tomorrow: until then, the server is down, but logs *are* still being collected | 22:46 | |
23:38
derpydoo joined,
derpydoo left
23:43
derpydoo joined
|