[04:40] *** zacts joined [05:20] *** zacts left [05:29] *** zacts joined [05:32] *** zacts left [09:34] *** qorg11 left [09:36] *** qorg11 joined [10:28] *** wingfold joined [11:45] *** MasterDuke left [11:51] *** MasterDuke joined [13:08] *** jgaz joined [13:11] *** TempIRCLogger joined [13:20] https://stackoverflow.com/questions/71702070/why-are-bench-modules-wallclock-seconds-report-so-wildly-off [13:20] anyone got any ideas on this? [14:28] How can I get machine epsilon or ULP in Raku? [14:53] *** jgaz left [15:07] Is there a filter function in Raku? [15:08] grep: https://docs.raku.org/type/List#routine_grep [15:10] *** discord-raku-bot left [15:11] *** discord-raku-bot joined [15:32] How can i use grep to filter out everything from a string, except numbers? I tried ``$string.grep: {"1234567890".contains($_)}``, but that doesnt seem to work [15:34] in Raku a string is an atomic entity, and you can only use .grep sensibly on lists [15:35] m: say "abc123ghi".subst(/ <[0123456789]> /, :g ) [15:35] rakudo-moar 530e17848: OUTPUT: «abcghi␤» [15:35] is probably more what you want ? [15:35] if the number can be any number, then: [15:35] m: say "abc123ghi".subst(/ \d /, :g ) [15:35] rakudo-moar 530e17848: OUTPUT: «abcghi␤» [15:36] Well, Liz beat me to it, but I also worked on answer... [15:38] Well, Liz beat me to it, but I also worked on a answer... [15:49] @stevied#8273 Inconsistent timings can result from (delayed) JITing or the GC kicking in. [15:55] well all that's above my ability to understand. but isn't timing wall clock seconds as easy as nothing the time something started and when it ended based on the the machine's clock? why would that not be accurate? [15:59] That part is accurate. But you cant execute a loop while it is being JITed, so that thread has to pause for a while. [16:04] no idea what that means, sorry. so anyway, how do I benchmark code? [16:05] is the Bench module even a useful tool? [16:07] Benchmark the whole bunch 10x and throw the first 2 rounds away. [16:16] so run the timethese method 10 different times? [16:18] is there something I can read that can at least get me some basic clue as to how a script is complied and run? I'm totally lost. [16:30] How can i use grep to filter out everything from a string, except numbers? I tried ``$string.grep: {"1234567890".contains($_)}``, but that doesnt seem to work [16:34] a substitution would probably be easier to write: `$string ~~ s:g/\d+//;` [16:35] wtf [16:35] that strips out numbers [16:35] if you wan to keep numbers, you'd do: [16:36] `$string ~~ s:g/<-[\d+]>//;` [16:36] that's a regular expression [16:36] what in that does what? [16:36] have you used regular expressions before? [16:36] nope [16:37] great tool. just about every language has them these days [16:37] at least ones I'm familiar with [16:38] see regex101.com [16:38] great site for helping you learn them [16:38] unfortunately, no Raku on that site yet [16:40] :C [16:40] no raku [16:41] but if you don't want to use regex, you could do a split method on the string and filter out undesired characters that way if you really want to use grep [16:42] how would that look? [16:42] well, to tdo the split, you'd do: say $string.split(''); [16:43] that returns a list (I think a list) [16:45] mmm, rather choose comb [16:45] if you really just want all characters one by one [16:45] split would give some awkward anchors in addition [16:45] so then you would do: `my $new_string = $string.split('').grep(/\d/);` [16:45] @Nemokosch#9980 Interesting / of course/ [16:45] @Nemokosch#9980 Interesting / "of course." [16:45] yeah, i'm not familiar with comb. haven't looked at that yet [16:45] actually, I guess you need a join after the grep [16:45] what is the /\d/? [16:47] that's a pattern that means decimal digit [16:47] `my $new_string = $string.split('').grep(/\d/).join('');` [16:47] so that line splits the string into a list of individual characters, matches the ones that are digits and puts them into a list, and then rejoins the list to create a new string [16:47] probably not the most efficient way of doing it, but that's how you can use grep [16:51] cool [16:51] but as pointed out, comb is better, for reasons I do not know [16:51] better than split [16:53] i can't tell if split returns a sequence or a list. i'm still fuzzy on a lot of this stuff myself [16:53] ok, it's a sequence. don't ask me the difference between a list and a sequence because I don't remember. [16:55] https://docs.raku.org/language/list [16:57] and how can i use grep, if i for excample only want the letters a, g and f? [16:59] change the pattern to <[agf]> [17:00] `my $new_string = $string.split('').grep(/<[agf]>/).join('');` [17:01] read this basic guide: https://raku.guide/#_regular_expressions [17:01] you'll definitely want to know regular expressions [17:01] what do these do? [17:02] find patterns in text [17:02] and answer questions for you: does this string contain the letter "a"? [18:11] *** wingfold left [18:55] stevied: isn't Bench running the code you give it multiples times and reporting the average time it took? so the total wallclock will be way more than the sum of the reported times [22:41] *** zacts joined [22:55] *** zacts left [23:16] I don’t know. No idea how it works. That’s what I’m trying to understand. I just assumed bench ran the function and times that one function. [23:17] It seems pretty straightforward with Perl. The wall clock time matches the time on my watch. Why it would be different in raku I don’t know [23:19] Though in my second experiment, it did match my watch time in raku. No idea what accounts for the very different behavior