This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
00:34
Manifest0 left
|
|||
drudgesentinel | I'm confused by an error I'm getting from a regex smartmatch. I'm seeing: Capture argument is not an object argument for captureposarg. Got 8 instead I can't figure out what this error means. I have simple testdata: [123412134. 123412341234] {foo: bar, veggie: potato, fruit: banana, component: splat} My intent is to split the contents of the square and curly brackets each into a separate capture group | 04:33 | |
(named) my $log-line-regex = {/$<unix-timestamp>=(\[.*\]) \s+ $<log-entry>=(\{.*\})/}; $log-line-regex<unix-timestamp> ~~ $line; I'm able to use regexr without issue, regexr.com/7l01l, so I assume that I'm utilizing capture groups incorrectly somehow. Any guidance would be appreciated | |||
nemokosch | I have never seen this error but to be fair, I have never seen this code pattern and I'm not sure this is even supposed to work | 05:11 | |
$log-line-regex is a Block, not a regex | |||
Oh right, and that was only the first line... the second line is much worse... | 05:13 | ||
What do you want to achieve? | 05:14 | ||
Oh right sorry, I didn't read that part | 05:15 | ||
05:16
deoac left
|
|||
But I still don't get the second line | 05:17 | ||
m: my $actually-a-block = { ... }; $actually-a-block<some-indexing> ~~ 'I hope this was a string' | 05:29 | ||
Raku eval | |||
nemokosch | This one survived at least | ||
I really need more context | 05:30 | ||
m: my $log-line-regex = {/$<unix-timestamp>=([.]) \s+ $<log-entry>=({.})/}; $log-line-regex.WHAT.say; $log-line-regex<unix-timestamp> ~~ 'some string'; | 05:44 | ||
Raku eval | (Block) | ||
nemokosch | Yeah, a Block. But not sure what $line can be that it explodes on you | ||
It just wouldn't do anything particularly useful. If you have a desired outcome for the variables, please do say | 05:45 | ||
05:50
apathor left
06:58
snonux left,
snonux joined
09:37
Manifest0 joined
|
|||
gfldex | fileknot.com/bf96e4f5c5ddbc07/Fall...g03_VR.exe | 11:15 | |
nemokosch | wrong chat? | 11:41 | |
snonux | hi, i have a make-config multi sub, which returns a Hash. i want to merge both hashes and return it from another multi sub. i found that this appears to work. the '% =' appears to enforce "hash context"? without it, the sub would return a List. is there a "better" way to do the same? but this appears to work: | 12:58 | |
multi sub make-config(Str:D :$config-file , Bool:D :$dry-run = False --> Hash) { | |||
# Merge default config with config file's config. | |||
% = make-config(:$dry-run), make-config(:$config-file); | |||
} | |||
nemokosch | %(...) is already a better way. % = ... is an assignment to an anonymous variable and you obtain the result of the assignment operation | 13:00 | |
snonux | ah, it is %(...), i tried {...} but it didn't work. | 13:02 | |
nemokosch | {...} is too ambiguous in the grammar, it prefers to turn into a Block marker if the slightest ambiguity arises | 13:03 | |
snonux | %(...) works, thanks :-) | ||
nemokosch | by the way, iirc %(...) really just calls .hash under the hood | 13:04 | |
(I guess it's not called .map because of the ambiguity with the mapping functionality) | |||
16:27
deoac joined
|
|||
rcmlz | Another approach - without counting threads manually is: Raku $*SCHEDULER = ThreadPoolScheduler.new( max_threads => Kernel.cpu-cores ); my UInt $BATCH = 2**10; #| Recursive, multi-thread, merge-sort implementation multi merge-sort-parallel ( @a where @a.elems < 2) { @a } multi merge-sort-parallel ( @a ) { my $m = @a.elems div 2; my @l = $m > $BATCH ?? start { samewith @a[ 0 ..^ $m ] } | 16:56 | |
!! samewith @a[ 0 ..^ $m ]; ... } gist.github.com/rcmlz/04948c16df5a...7144c74b0d | |||
antononcube | @rcmlz Are you Python user/programmer by any chance? | 17:01 | |
18:33
stanrifkin joined
20:54
stanrifkin left
21:06
guifa left
21:07
guifa joined
21:31
NemokoschKiwi joined
22:08
Manifest0 left
22:26
NemokoschKiwi left
22:44
deoac left
23:12
deoac joined
23:18
jgaz left
|