šŸ¦‹ 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:59 greppable6 left, coverable6 left, bloatable6 left, evalable6 left, bisectable6 left, tellable6 left, unicodable6 left, committable6 left, releasable6 left, statisfiable6 left, notable6 left, sourceable6 left, shareable6 left, quotable6 left, linkable6 left, benchable6 left, squashable6 left 01:00 coverable6 joined, unicodable6 joined 01:01 squashable6 joined, bisectable6 joined 01:02 committable6 joined, evalable6 joined, linkable6 joined, benchable6 joined 01:04 frost left 01:10 RandalSchwartz left
tbrowder .tell Util ^^^ 01:20
.tell Util ^^^ 01:21
01:34 frost joined 02:01 frost left 02:18 notable6 joined 02:25 gordonfish left, gordonfish joined 02:38 nativecallable6 joined 03:05 Sgeo left 03:19 tellable6 joined 03:28 Sgeo joined 03:50 bloatable6 joined 04:04 greppable6 joined 04:08 tejr left 04:16 squashable6 left 05:07 mr_nice_guy joined 05:09 mr_nice_guy left 05:17 shareable6 joined 05:36 Juerd left 05:50 releasable6 joined 05:58 tejr joined 06:04 reportable6 joined 06:10 codesections left 06:29 Juerd joined 06:37 Doc_Holliwood joined 06:44 Juerd left 06:46 Juerd joined, Eddward_ left 07:46 gugod left 07:54 gugod joined 08:12 Doc_Holliwood left, Kaiepi left 08:20 Kaiepi joined 08:26 Kaiepi left 08:39 Kaiepi joined, frost joined 08:46 Sgeo left 09:04 statisfiable6 joined 09:22 sono left 09:31 tejr left 09:33 tejr joined 09:43 sourceable6 joined 09:44 frost left 09:46 frost joined 09:50 frost left 10:45 sivoais left 10:46 sivoais joined 10:53 abraxxa-home joined 11:18 abraxxa-home left 11:31 StayHungry joined
StayHungry Errā€¦ Good afternoon, comrades :) 11:32
By accident, I found out about Raku, while learning about scripting languages, and here I am 11:35
While I was filling out this table - dpaste.org/QSC0/slim - Perl failed to offer a way to parse dates beyond Unix epoch (possible only by means of installing remote modules). I wonder if Raku is capable of that natively? 11:37
MasterDuke it is docs.raku.org/type/Date#method_new 11:40
nine Being able to parse ISO-8601 dates is what I miss most in Perl's DateTime... I know there's a parser module, but I always have to look up its name and DateTime::Format::ISO8601->parse_datetime($datetime_str) is a real mouth full. 11:45
StayHungry MasterDuke: not quite that... or i miss something. since date is 23-07-1821, i cannot simple say date.new(...). there should a way to attach format like %d-%m-%Y 11:48
MasterDuke yeah, the built in date functions can take an optional output formatter, but i don't believe any take an input format 11:53
tbrowder is the person to ask about datetime stuff, he's been working in that area recently 11:54
StayHungry tbrowder? ok. let's wait for him. so far i can fill out two other variants i guess, i.e. split/reverse/join and reordering of regex groups 11:55
i was suprised how Perl dealt with regex processing at first 12:00
other languages tend to do the following: gsub('string', 'search', 'replace') 12:01
so it's clear where to put your string
with Perl it is a bit different as follows print '23-07-1821' =~ s/(\d+)-(\d+)-(\d+)/$3-$2-$1/r
mind both =~ and /r
of course, these things could learnt by heart, yet are not that obvious 12:02
wonder if Raku does it the same way
12:02 reportable6 left 12:05 reportable6 joined 12:10 xinming left
StayHungry yeah, obviously changed something as say '23-07-1812'.subst(/(\d+)-(\d+)-(\d+)/,/$3-$2-$1/, :g)" does not work 12:20
tbrowder StayHungry: hi, i have to leave in a few minutes, but how can i help! 12:27
?
StayHungry tbrowder: can Raku parse 23-07-1812 as date by defining input format dd-mm-yyyy? 12:28
tbrowder the % time formats i believe someone is working on
i don't know for sure about yr question but i don't think so 12:29
i don't think anyone is in favor of adding a new parse method to core, though, just ask lizmat 12:31
StayHungry tbrowder: [ ] ask lizmat about date parsing 12:32
thank you, sir
tbrowder you're very welcome, see you later, bye... 12:34
StayHungry raku... racooooon :D 12:35
moritz www.emilydamstra.com/please-enough...tterflies/ 12:42
relevant for our mascot
StayHungry moritz: 'dead butterfly on a pillow'... oh my, how to sleep afterwards 12:49
moritz StayHungry: I, for one, couldn't sleep on a pillow with a living butterfly on it 12:50
lizmat I'd argue that Camelia is a butterfly that is very much alive 12:51
StayHungry comrades, lend a helping hand :) i'm confused with raku's regexes 12:55
why say '23-07-1812'.subst(/(\d+)-(\d+)-(\d+)/, /$3-$2-$1/, :g) does not work? 12:57
12:59 Eddward_ joined 13:08 Eddward_ left
StayHungry by trial and error found a working variant, but its syntax is like from hell 13:08
say '23-07-1812'.subst(/(\d+)'-'(\d+)'-'(\d+)/, {"$2-$1-$0"}, :g);
evalable6 1812-07-23
StayHungry that '-' inside search pattern, that { } in replace pattern, not to mention double quotes 13:09
tell me there is a simpler way without all that? 13:10
moritz m: $_ = ''23-07-1812'; s/(\d+) \- (\d+) - (\d)/$3-$2-$1/; .say
camelia 5===SORRY!5=== Error while compiling <tmp>
Two terms in a row
at <tmp>:1
------> 3$_ = ''7ā0523-07-1812'; s/(\d+) \- (\d+) - (\d)/$3-
expecting any of:
infix
infix stopper
statement end
staā€¦
moritz m: $_ = '23-07-1812'; s/(\d+) \- (\d+) - (\d)/$3-$2-$1/; .say 13:11
camelia 5===SORRY!5===
Unrecognized regex metacharacter - (must be quoted to match literally)
at <tmp>:1
------> 3$_ = '23-07-1812'; s/(\d+) \- (\d+)7ā5 - (\d)/$3-$2-$1/; .say
Couldn't find terminator /
at <tmp>:1
------> 3$_ = '23-07-1ā€¦
moritz m: $_ = '23-07-1812'; s/(\d+) \- (\d+) \- (\d)/$3-$2-$1/; .say
camelia Use of Nil in string context
-1-07812
in code at <tmp> line 1
moritz m: $_ = '23-07-1812'; say S/(\d+) \- (\d+) \- (\d)/$3-$2-$1/;
camelia Use of Nil in string context
-1-07812
in code at <tmp> line 1
moritz a bit rusty, something like that should work
StayHungry well, there are 150+ users here... come on, sleepy kingdom, share some wisdom :) 13:12
moritz escaping the - is necessary, because in raku regexes, any non-word characters either a special meaning or are reserved 13:13
so you don't have to remember arbitrary lists like +*.? have special meanings but -?/ do not 13:14
El_Che (building linux packages for new release, atm; doing a test run) 13:17
StayHungry moritz: ok, '-' is replaced by \- 13:19
moritz: what about scary {"$2-$1-$0"} part?
(why first element has $0 instead of $1... zero is nothing since its invention... ) 13:20
and official docs has no multi groups example, aggrrhh 13:23
moritz in the method form, have to pass a closure to subst, otherwise the $1 etc will be interpolated into the string *before* it's passed to .subst 13:26
which the s/// form should not suffer from
m: $_ = '23-07-1812'; say S/(\d+) \- (\d+) \- (\d)/$2-$1-$0/; 13:27
camelia 1-07-23812
moritz m: $_ = '23-07-1812'; say S/(\d+) \- (\d+) \- (\d+)/$2-$1-$0/;
camelia 1812-07-23
moritz StayHungry: better?
s/// modifies in-place, S/// returns a modified copy 13:28
StayHungry is it possible to do without variable?
say 'foobar' ~~ s!foo!fox! 13:29
say 'foobar' ~~ s!foo!fox!;
:( 13:30
moritz start with `m:' to talk to the bot
and you cannot replace in a string literal, just in a variable 13:31
StayHungry but perl -e "print '23-07-1821' =~ s/(\d+)-(\d+)-(\d+)/$3-$2-$1/r" works
raku excluded that?
moritz m: say 'foobar' ~~ S!foo!fox!
camelia Potential difficulties:
Smartmatch with S/// is not useful. You can use given instead: S/// given $foo
at <tmp>:1
------> 3say 'foobar' ~~ 7ā5S!foo!fox!
False
moritz m: say S!foo!fox! given 'foobar'
camelia foxbar
moritz s///r corresponds to S/// 13:32
StayHungry m: say S!(\d+)\-(\d+)\-(\d+)!$2-$1-$0! given '23-07-1812' 13:33
camelia 1812-07-23
StayHungry at last :)
moritz: what about rx? does it apply here, or it's for different cases? 13:36
13:39 ming joined
StayHungry m: split('-','23-07-1812').reverse.join('-').say 13:56
camelia 1812-07-23
StayHungry m: split('-').reverse.join('-').say given '23-07-1812' 13:57
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling split(Str) will never work with signature of the proto ($, $, |)
at <tmp>:1
------> 3<BOL>7ā5split('-').reverse.join('-').say given '
StayHungry heh
13:58 Xliff joined
Xliff lizmat: gist.github.com/Xliff/6eb22faa3a79...45ce429294 13:58
StayHungry m: split('-').reverse.join('-', $_).say given '23-07-1812'
camelia 5===SORRY!5=== Error while compiling <tmp>
Calling split(Str) will never work with signature of the proto ($, $, |)
at <tmp>:1
------> 3<BOL>7ā5split('-').reverse.join('-', $_).say giv
StayHungry m: split('-', $_).reverse.join('-').say given '23-07-1812'
camelia 1812-07-23
lizmat Xliff: cool! 14:01
afk& 14:02
Xliff: wonder if you could lose one level of indirection by using ^add_method('BlackPixelOfScreen',&XBlackPixelOfScreen) 14:04
on the Screen class I mean
hope I made sense
hope I made sense 14:05
really afk&
StayHungry m: say '23-07-1812'.split('-').reverse.join('-') 14:09
camelia 1812-07-23
Xliff lizmat: That blog isn't about writing dynamic classes. It' 14:10
StayHungry yeah, far more clear than print join '-', reverse split /-/, '23-07-1821'
Xliff lizmat: It's about generating source code. :) 14:11
Feel free to write up something in the comments about that, though!
14:19 Manifest0 left 14:20 Manifest0 joined 14:28 Manifest0 left
El_Che weekly: github.com/nxadm/rakudo-pkg/releas...g/v2021.07 15:15
notable6 El_Che, Noted! (weekly)
15:20 Doc_Holliwood joined 15:28 codesections joined 15:30 notna joined 15:38 Sgeo joined
Altai-man El_Che++ 15:48
16:01 StayHungry left
Util tbrowder: the Raku Study Group was moved (permanently? one-time-only? to be determined!) this week from Sunday to Saturday. 16:09
I did attend it yesterday.
mykhal I have problem with inverting hash with object values to object hash. This looks fine: 16:14
16:14 tejr left
mykhal m: my %h = ( a => 1, b => (2, 3) ) ; say %h.antipairs 16:14
camelia ((2 3) => b 1 => a)
mykhal .. but keys are flattened to strings when stored to variable. I did tru :{} trick as wel ... 16:15
16:15 tejr joined
mykhal m: my %h = ( a => 1, b => (2, 3) ) ; my %hh = %h.antipairs; say %hh.raku 16:16
camelia {"1" => "a", "2 3" => "b"}
mykhal i can assign to $hh, look ok, but then I cannot do associative indexing 16:18
or can i? 16:19
m: my %h = ( a => 1, b => (2, 3) ) ; my $hh = %h.antipairs; say $hh
camelia (1 => a (2 3) => b)
mykhal m: my %h = ( a => 1, b => (2, 3) ) ; my $hh = %h.antipairs; say $hh{1} 16:20
camelia Type Seq does not support associative indexing.
in block <unit> at <tmp> line 1
mykhal m: my %h = ( a => 1, b => (2, 3) ) ; my $hh = :{ %h.antipairs }; say $hh{1} 16:21
camelia Type Block does not support associative indexing.
in block <unit> at <tmp> line 1
mykhal m: my %h = ( a => 1, b => (2, 3) ) ; my %hh = :{ %h.antipairs }; say %hh{1} 16:22
camelia Odd number of elements found where hash initializer expected:
Only saw: -> ;; $_? is raw = OUTER::<$_> { #`(Block|58702264) ... }
in block <unit> at <tmp> line 1
16:28 quotable6 joined 16:29 Doc_Holliwood left 16:37 renormalist joined
mykhal oh, there's a Rakudo problem note in docs.raku.org/language/hashmap#Non...ject_hash) 16:42
16:44 Doc_Holliwood joined 16:48 ming left 16:49 ming joined
tbrowder Util: thnx 16:51
.ask StayHungry can you describe your DateTime use case or problem again? i've trained myself for the last 15 plus years to always use the ISO date form, so if i use data from another source and format i just whip up a raku script to convert it (and save the script for future use). i can't believe it in this era but i see at least one of my local gov't agencies still using xx/xx/yy format (where the xx's are not always unambiguous)! 17:10
thank goodness it's not my bank or doctor.
tellable6 tbrowder, I'll pass your message to StayHungry
phogg tbrowder: I'm with you, but I've had some Europeans argue against ISO8601, preferring DD-MM-YYYY as more convenient. This is a big-endian vs. little-endian argument again. 17:13
tbrowder .tell StayHungry try raku module DateTime::Parse 17:14
tellable6 tbrowder, I'll pass your message to StayHungry
tbrowder phogg: to me dd-mm-yyyy is also fraught with uncertainties, at least in isolation, and the sort issue, erg... 17:16
17:18 Doc_Holliwood left
mykhal phogg: some europeans get fury when seeing semthing like 23-07-1821, or did July 23 AD have almost 2k days ? rather use 23.07.1821 17:24
.. July of the year 23 AD
17:32 Doc_Holliwood joined
mykhal m: my %h = (a=>(0,1),b=>(2,3)); my %H = Hash[Str,List].new; for %h.kv -> $k,$v {my Str %H{List} = ($v => $k)}; say %H 17:33
camelia {}
17:36 ming left 17:47 notna left 18:02 reportable6 left 18:36 olve joined
olve Hi all 18:40
Question, please:
this works:
________________________________
use HTTP::UserAgent;
my HTTP::UserAgent $useragent .= new;
````````````````````````````````
whereas this:
________________________________
require HTTP::UserAgent;
my HTTP::UserAgent $useragent .= new;
````````````````````````````````
throws:
________________________________
Package 'UserAgent' is insufficiently type-like to qualify a variable
````````````````````````````````
dropping type-constraint works fine:
dropping type-constraint works fine: 18:41
________________________________
18:41 discord-raku-bot left 18:42 discord-raku-bot joined 18:43 olve_ joined
Util m: my List %h{Str} = a => (0,1), b => (2,3); my Str %H{List}; for %h.kv -> $k,$v {%H{$v} = $k}; say %H; 18:47
camelia {(0 1) => a, (2 3) => b}
Util m: my List %h{Str} = a => (0,1), b => (2,3); my Str %H{List} = %h.antipairs; say %H;
camelia {(0 1) => a, (2 3) => b}
Util mykhal: ^^^ Using `my` inside the loop shadowed the variable, making it a different %H than you inspected after the loop. 18:49
Also .antipairs is a short form of the reversal of key and value.
my TypeOfValue %hashName{TypeOfKey} is the declaring syntax I use. Hash[Str,List] might be fine, but I am not familiar with it. 18:51
MasterDuke olve: docs.raku.org/language/modules#require says the importing of symbols happens at runtime with require. so you could do `BEGIN require HTTP::UserAgent` and then it'll work
but if you can't use BEGIN, i'm not sure of a way to declare and initialize the variable like that. `require HTTP::UserAgent; my $useragent = HTTP::UserAgent.new;` does work though 18:53
mykhal Util: thanks, I did try .antipairs much simpler way, the issue is inverting to object hash, see approx 2Ā¾ hrs ago 18:59
19:00 Xliff left
olve MasterDuke: thanks for your reply. But: 19:10
`BEGIN require` effectively turns runtime loading into compile time loading, and if one wants specifically a runtime loading, then how one is supposed to type-constrain?
Is the mentioned behavior what is meant to be proper Raku, or is it some sort of not-yet-implemented?
19:10 discord-raku-bot left
mykhal Util: .. I did not managed to do it this even with this verbose and iterative way 19:11
19:11 discord-raku-bot joined
mykhal i did died almost from it :) 19:12
MasterDuke olve: dunno. moritz, lizmat, or timo might be good people to ask 19:15
or vrurg
19:29 Manifest0 joined, olve_ left
vrurg olve: There is no many solutions in this case, unfortunately. The closes one would be a `where` block matching against run-time resolution with ::('A::Type'). 19:46
19:46 olve__ joined
vrurg A subset with `where` would also do and would look better than a bare `where` alongside with a declaration. 19:47
19:50 Olve_ joined
MasterDuke olve: `require HTTP::UserAgent; my subset HUA where ::("HTTP::UserAgent"); my HUA $useragent = HTTP::UserAgent.new;` works. but assigning something other than an HTTP::UserAgent will throw a runtime error and you still can't use `.= new` 19:53
olve vrurg, MasterDuke: šŸ‘ļø 20:03
20:13 StayHungry joined
StayHungry lizmat: still afk, sir? 20:13
tellable6 2021-07-25T17:14:41Z #raku <tbrowder> StayHungry try raku module DateTime::Parse
hey StayHungry, you have a message: gist.github.com/7d43fb47d5e27bd676...f3f38773bc
StayHungry tbrowder recommended to ask you if Raku had a way to parse 23-07-1821 as dd-mm-yyyy and then convert to yyyy-mm-dd 20:16
without installing remote modules (as Per5 does)
lizmat I don't listen to "sir" :-) 20:20
some of the people on this channel, are actually of the female persuasion :-) 20:21
gfldex goes to check what kind of music "sir" play
lizmat didn't backlog yet, am in the middle of some other stuff atm
StayHungry lizmat: errā€¦ you're she? o_O 20:22
lizmat :-)
StayHungry lizmat: ahemā€¦ perhaps date parsing is not your field either? 20:24
lizmat not really, no.... but I did work a lot on the Date / DateTime modules to make them faster :-) 20:25
s/modules/classes
StayHungry i wonder whom to ask then *confused* 20:26
lizmat StayHungry: perhaps you could repeat the question, so I don't need to backlog now ? 20:31
StayHungry tbrowder recommended to ask you if Raku had a way to parse 23-07-1821 as dd-mm-yyyy and then convert to yyyy-mm-dd without installing remote modules (as Per5 requires to get one called DateTime::Format::Strptime from CPAN) 20:32
for example, PHP and PowerShell do it as follows 20:33
echo datetime::createfromformat('d-m-Y', '23-07-1821')->format('Y-m-d');
[datetime]::parseexact('23-07-1821', 'dd-MM-yyyy', $null).tostring('yyyy-MM-dd')
in R: '23-07-1821' |> as.Date('%d-%m-%Y') |> format('%Y-%m-%d') |> cat() 20:34
lizmat m: dd "1821-07-23".Date # so you want to work that for "23-07-1821"
camelia Date.new(1821,7,23)
StayHungry task is 23-07-1821 -> 1821-07-23 20:36
so far Raku allows to
say '23-07-1812'.split('-').reverse.join('-')
evalable6 1812-07-23
StayHungry say S/(\d+)\-(\d+)\-(\d+)/$2-$1-$0/ given '23-07-1812'
evalable6 1812-07-23
StayHungry and i wonder if Raku is capable of the 3rd way, i.e. parse string with custom input date format and convert it to custom output date format 20:37
lizmat it isn't in core, from what I know
StayHungry that's what i wanted to know, thank you
lizmat sorry that I didn't get that earlier... :-)
StayHungry (-: 20:38
lizmat I find the idea of a .Date('%d-%m-%Y") intriguiing
Util StayHungry: DateTime::Format::strptime would work, but it is marked as NYI (Not yet implemented).
DateTime::Parse does the kind of thing that you want, but I think it has to already know about your intended format, and it does not. (Error: "Unable to parse 23-07-1812"). 20:39
StayHungry Util: DateTime::Format::Strptime is a remote module, thus not applicable in my case which i mentioned earlier. only native ways.
Util StayHungry: I missed that restriction. lizmat: I concur, not currently in core. 20:41
StayHungry Util: you could see which popular scripting languages are capable of that in my table dpaste.org/STqW/slim
lizmat StayHungry: would you consider NativeCall core or not?
Util split+reverse+join is concise, and might be best for your table-of-comparisons.
lizmat if so, maybe calling libc's strptime() function could be a solution? 20:42
StayHungry lizmat: you're the boss, you tell me. if nothing extra is required to be downloaded, then i'm curious :)
lizmat it's part of the standard distribution, but you need to do a "use NativeCall" to activate
m: use NativeCall 20:43
camelia ( no output )
Util In production code, I would use a more specific regex like S/(\d\d)\-(\d\d)\-(\d\d\d\d)/ to warn of bad input.
StayHungry lizmat: i'm ready to active NativeCall, but what then? :)
lizmat well...then you need to get into C programming :-) 20:44
so maybe not a good suggestion after all
are your DD-MM-YYYY dates always well-formed?
StayHungry C... i see... a little bdsm for the night :D yes, Liz, they are 20:45
lizmat m: sub d($d) { Date.new: .substr(6),.substr(3,2),.substr(0,2) given $d }; dd d "23-07-1821" 20:47
camelia Date.new(1821,7,23)
lizmat would that help you?
StayHungry hacky one :))
lizmat will perform pretty well
vrurg a bit more reliable is to rely on '-' been the separator. then `DateTime.new: split('-')[2,1,0]` 20:48
StayHungry but it's not really a date parsing with chosen format ,) it's a variation of say '23-07-1812'.split('-').reverse.join('-')
vrurg With split it won't rely on 0-prefixed days and months. 20:49
Util lizmat: StayHungry is working on (please corect me if I am wrong!) the Raku entry for this table:
dpaste.org/QSC0/slim
StayHungry yeah, learning by comparing :) 20:50
lizmat ah, so you're only interested in creating a *string* of the right format, not an actual Date object? 20:51
Util just saw that the link was already posted, half a screen back. oops.
lizmat is trying to follow several parallel discussions :-) 20:52
StayHungry Util: you posted an old one, fresh one is dpaste.org/STqW/slim
lizmat: yes, parse '23-07-1821' as 'dd-mm-yyyy' then convert to 'yyyy-mm-dd' 20:53
well, i guess we did our best, Raku is young and the most promising features are yet to come :) 20:54
lizmat then it is not really about the validity of the date anyway
none of the solutions appear to check validity 20:55
and the python solutions appear to load external modules?
anyways, I think I've given it my best shot, hope it helped, StayHungry
afk again& 20:56
StayHungry thank you for your kind attention, lizmat
python solution loads a module included with default installation 20:57
other than that, i like how syntax of Raku evolved over Perl 5 20:58
print join '-', reverse split /-/, '23-07-1821' is still a bit hard to grasp 20:59
whereas say '23-07-1812'.split('-').reverse.join('-') is far closer to how i think and speak :D
alas, execution speed is the issue. perl5 takes ~30ms on my end, raku ~250ms 21:01
Util StayHungry: Glad you like it! Since you are interested in cross-lang comparison, do you know about rosettacode.org ?
StayHungry yes, sir :) it was one of inspiration points
Util Great! (and yes, performance is an ongoing struggle) 21:02
StayHungry what makes Raku slower?
gfldex About 20 years of work.
StayHungry it takes the same 250ms as PowerShell 5 which is linked to sluggish .NET, but Raku...
gfldex: but Perl5 ~30ms 21:03
Util chromatic observed (at some point) that Raku beats Perl in speed... *if* you load into Perl all the things that Raku has built-in, like Rats, no-limit-Integers, real object support, etc. 21:04
gfldex If you stuff a Perl script with enough modules to get the same features as Raku, you wont get 30ms.
StayHungry so Raku at this point is more powerful then Perl5 out of the box already? 21:05
gfldex Rakudo is not fast yet. There is plenty of work to do.
Util StayHungry: The design of Raku varies from a little more powerful to vastly more powerful, depending on which piece you examine, and what modules you are willing to load in Perl. 21:07
StayHungry Util: yes, i like how split/reverse/join array part has evolved, but still getting used to how regex changed
s/(\d+)-(\d+)-(\d+)/$3-$2-$1/ vs S/(\d+)\-(\d+)\-(\d+)/$2-$1-$0/
moon-child well, depends on how you qualify 'features'. THere's an extent to which you pay for the features you don't use
(and an extent to which you can avoid them, using e.g. native-sized ints) 21:08
Util wants *all* the features. (but I do take your point)
StayHungry i come from humanities, so $0 for me is like wat? 0 is nothing since its invention as you know :) and escaping - is also new
moon-child 0 was controversial for many millenia. People were executed for claiming its existence. It was an _excellent_ innovation, however 21:09
Util In programming, almost everyting starts from zero. Perl made an exception because many programmers where were coming to Perl from elsewhere expected $0 to be the name of the current program.
moon-child maybe not 'many', but
Util So, forever more, in Perl I had the headache of "It is in $z[0] when I assign `@z = /(the) reg ex/, but in $1 otherwise", and off-by-one errors are more likely. 21:11
StayHungry Util: but check the table, only Raku sticks to $0 for 1st element of group, even oldschool awk does not :)
Util Yes, `awk` was one of the `elsewheres`! 21:12
21:13 evalable6 left, linkable6 left
Util moon-child: Yes, I am a better story-teller than I am a historian. Thanks! 21:14
21:14 linkable6 joined 21:15 evalable6 joined
moon-child history _is_ story-telling, like everything else 21:16
21:16 reportable6 joined
StayHungry say $_.split('-').reverse.join('-') given '23-07-1812' 21:18
evalable6 1812-07-23
StayHungry wow :)
Util moon-child: :^) 21:19
StayHungry: You can also drop the $_ , because it is implied by a bare dot before the method name. 21:20
StayHungry o_O
Util If you are golfing it down, `.split('-')[2,1,0]` beats `.split('-').reverse` 21:21
StayHungry let's see... 21:22
actually something like that i used somewhere...
yes, in PowerShell '23-07-1821'.split('-')[2..0] -join '-'
Util In Raku, you would need three dots to make 2...0 work. 21:23
StayHungry diligently makes notes
Util Two dots is a simple range, and the start cannot be higher than the end, or you get nothing (empty list). 21:24
Three dots is the `sequence` operator, and it has enormous superpowers. Being able to go "downwards" is the least of its tricks. 21:25
StayHungry say '23-07-1812'.split('-')[2...0].join('-')
evalable6 1812-07-23
StayHungry \(^__^)/
Util :) 21:26
StayHungry is there some internal command in Raku to measure execution time?
MasterDuke m: say now - INIT now 21:27
camelia 0.000329592
moon-child I think people more usually use ENTER
easier to bench multiple things at once that way, just put them in different scopes
MasterDuke that's not a good idea though
moon-child m: { sleep .5; say now - ENTER now }; { sleep .2; say now - ENTER now }
camelia 0.500623292
0.200160723
MasterDuke spesh/jit frequently will optimize for the first things it sees, which can cause later things to run slower than they would otherwise 21:28
StayHungry sorry, i must be missing something here: raku -e "say now '23-07-1812'.split('-')[2...0].join('-') now" -> error 21:32
moon-child you have an exterraneous 'now' 21:33
StayHungry so it should be '23-07-1812'.split('-')[2...0].join('-'); say now; ? 21:34
it outputs Instant:1627248953.6200648 which i am confused to 'decipher' 21:35
Util It might be clearer like this: 21:36
m: my $t = now; say '23-07-1812'.split('-')[2...0].join('-'); say now - $t; 21:37
camelia 1812-07-23
0.003592873
StayHungry now i see human-readable 0.0120007 :) thank you 21:38
guess, i'm a bit spoiled by PowerShell in that matter, they simply wrap code with Measure-Command { ... } 21:39
Util `now` is this moment in time. `ENTER now` and `INIT now` are tricks to get moments in time during the block-entrance or Raku-initialization, and deliver those remembered moments during the execution of the surrounding expression.
Most such one-off measurements are very unreliable on modern systems, since so much else is going on all the time on desktops and laptops. 21:41
For good thoughts on good methodology, see www.perl.com/article/40/2013/9/29/...for-speed/
Raku has: modules.raku.org/search/?q=benchmark 21:42
StayHungry "...to get moments in time..." and I recall another line "I've watched see Beams glitter in the dark near the Tannhauser Gateā€¦ all those moments, will be lost in time like tears in rainā€¦" (fom Blade Runner)
Util :) 21:43
afk, to finish theweeklychallenge.org/blog/perl-w...122/#TASK2
StayHungry is checking links 21:45
Util StayHungry: Only 1h13m until this week ends. The next one will start tomorrow, though. Oh, even if you don't play, have a look; lots of other languages are getting used now, so rich rich field for comparison! 21:48
StayHungry i wonder why a butterfly is the mascot, not a raccoooooon :) 21:53
and that butterfly is so psychedelic, almost nsfw 21:56
tbrowder howdy, raku ppl 21:57
question: when i pass a named param to a sub in which the param is not defined, why don't i get a warning or exception? 21:59
m: sub foo(:$debug) {say "foo"}; foo(:bar(1)); 22:01
camelia Unexpected named argument 'bar' passed
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
StayHungry from Wiki: "One of the goals behind the lively and colorful design of the logo was to discourage misogyny in the community and for it to be an opportunity for those of "masculine persuasion" to show their sensitive side."
tbrowder hm, i must be doing something weird 22:02
22:04 Eddward_ joined
tbrowder m: multi sub foo($a, :$debug) {say "foo"}; foo(: 22:04
camelia 5===SORRY!5=== Error while compiling <tmp>
Preceding context expects a term, but found infix : instead.
at <tmp>:1
------> 3 sub foo($a, :$debug) {say "foo"}; foo(:7ā5<EOL>
expecting any of:
colon pair
tbrowder m: multi foo($a, :$debug) {say "foo"}; foo(7, :bar); 22:05
camelia Cannot resolve caller foo(Int:D, :bar); none of these signatures match:
($a, :$debug)
in block <unit> at <tmp> line 1
StayHungry Util: thank you for a warm welcome and further details 22:10
Util StayHungry: yw! 22:11
StayHungry said 'that' given 'warm welcome' :D
mykhal i like that secret naive-word-wrapper, except that it makes 2 spaces after period 22:12
Util tbrowder: We covered that exact annoyance (named param should warn you) in the Study Group yesterday.
tbrowder: I can't recreate my rant^Wexplaination here. See design.raku.org/S12.html#Interface_Consistency . 22:17
m: say pi.cos(:why_will_you_not_tell_me_this_is_bad); 22:18
camelia -1
gfldex Don't we got a slang for that? 22:19
Util perks his ears up at gfldex's words 22:20
gfldex github.com/nxadm/StrictNamedArguments 22:22
Util gfldex: Thanks! That will help with our own classes, but it is really the built-ins that casue my problems, like trying to say .max(:by{+.size}) , when `:by` is only used in the *sub* form. 22:31
22:38 StayHungry left
Util tbrowder: oh, to be clear, sub calls will catch bad named params. It is only the method form of call that has this "Interface_Consistency" issue with ignoring bad named params. 22:43
mykhal Util: ok, so i have done rosettacode nocheat mode Bacon cipher without inverted object hash did with strings. More interesting is, that i'm doing in-place list modification on discontinous projected sublist implemented with list of 1-char lists. maybe it can be done more elegantly. rosettacode.org/wiki/Bacon_cipher#...r_solution 22:49
tbrowder ok, thnx, bruce, i swear i saw it in a sub, but iā€™m probably forgetting it now ā€˜cause i was coding hot and heavily. i do know at least one was in a method. 22:50
Util mykhal: I will need more time to grok the more interesting part, so right now (travelling by car) I can only smile and enjoy the conceptual density of your expression of the broader solution. 23:37
Looks great!
23:38 linkable6 left, evalable6 left 23:39 evalable6 joined
Util I did play with hoisting the innermost `if` condition, and saw something odd. 23:39
When I create a pre-evaluated hash just after %bacon, as in `my %bacon_bool = %bacon.sort.map({ .key => .value.combĀ».IntĀ».Bool });` 23:40
23:40 linkable6 joined
Util , I started refactoring the inner loop to a single statement (which you might not care for), and noticed that all three uses of [0] could be removed, without changing the output. 23:42
Could it be that your list of 1-char lists
would be simpler as just one-level of list-of-single-chars? 23:43
To be clearer, I didn't need to say any of that, except the last three lines. :^( 23:45
Does look great though. Did not mean to retract that part! 23:46