Skip to main content
Filter by
Sorted by
Tagged with
1 vote
2 answers
62 views

How do I get a count of duplicate lines using Raku?

When using a CLI it is possible to pipe the contents of a fil through uniq. Is there an analogy of the GNU uniq -c function in Raku ? For example, one two one three one two four five is transformed ...
Richard Hainsworth's user avatar
4 votes
1 answer
61 views

What is an idiomatic way to convert a query to a hash

The response to an HTTP request is a string like 'one=iwejdoewde&two=ijijjiiij&three=&four=endinghere' I want to put this query into a hash. My solution is my $s = 'one=iwejdoewde&two=...
Richard Hainsworth's user avatar
6 votes
2 answers
183 views

How to use gather/take with race

I can parallelize execution using Hyper and it works: $ raku -e 'race for (^8).race(batch => 1, degree => 4) {sleep rand; .say}' 0 3 5 2 1 7 4 6 But how can I add gather/take behavior to such ...
Pawel Pabian bbkr's user avatar
4 votes
2 answers
149 views

How to make altering a deep field more idiomatic

I have a hash with several layers of sub-hashes, and I want to alter all the modified fields in the bottom layer. The hash has the following structure %sources{$lang}{$filename}{$attribute} The code ...
Richard Hainsworth's user avatar
6 votes
0 answers
140 views

Writing async routines: use `start` or `Promise.then`?

I'm looking for the right way to write asynchronous routines. Here's a hypothetical example of some asynchronous javascript function: async function someFunction() { const data = await Promise....
fingolfin's user avatar
  • 874
4 votes
1 answer
111 views

How to explicitly use the default value of a parameter?

Let's say we have the following subroutine: sub test($arg = 'defaut value') { say $arg } And we want to pass some argument that will cause the subroutine to use the default value, something like this:...
fingolfin's user avatar
  • 874
5 votes
1 answer
133 views

Using Recursive Regexes in Raku: how to limit recursion-levels?

Raku has an interesting and exciting recursive-regex notation: <~~>. So in the REPL, we can do this: [0] > 'hellohelloworldworld' ~~ m/ helloworld /; 「helloworld」 [1] > '...
jubilatious1's user avatar
  • 2,361
3 votes
1 answer
158 views

Really slow compilation of a big grammar [closed]

Reproducing Sorry, I couldn't come up with an MRE. My code is on glot.io. It isn't perfect, because it's autogenerated. Here are steps to reproduce: Step 1 Compile the code: time raku --stagestats ...
fingolfin's user avatar
  • 874
4 votes
2 answers
136 views

Is it ok to use binding when declaring variables?

I keep asking questions about sets in Raku to several AIs. Now I asked again a question about sets in Raku to Deepseek. It gave me the following example # Create a mutable SetHash my %set := SetHash....
zentrunix's user avatar
  • 2,266
5 votes
3 answers
131 views

I need a Raku grammar to change itself based on a different match

I want to write a Raku grammar to check a monthly report about work contribution factors, written in Racket/Scribble. The report is divided, at the highest level, into monthly sections, and beneath ...
sailortailorson's user avatar
6 votes
1 answer
80 views

Inheriting from Array: construction

There is an example: class A is Array { has $.member = 42; } my $a = A.new: 1..10; say $a.member; # OUTPUT: «(Any)␤» Why doesn't it work? I also tried submethods TWEAK and BUILD, they also can't ...
fingolfin's user avatar
  • 874
9 votes
1 answer
384 views

Is there a way to have a short and two long command line argument alternatives for a parameter?

I have guessed multiple syntax variations to achieve this in a single line in the MAIN function. I know I could achieve it in two separate lines, but am looking for the cleaner solution and only ...
David Gordon's user avatar
5 votes
1 answer
123 views

Copy some hash elements to another hash

Is there a more idiomatic way to create a hash with a sub-set of keys from another hash. Currently I have: a-subroutine('param', %(:$level, :id(%prm<id>), :target(%prm<target>), ...
Richard Hainsworth's user avatar
6 votes
2 answers
113 views

How do I install the Raku Cro web framework using a dockerfile

I am attempting to wrap a Raku based web app in a dockerfile. I am using the Cro web framework but I cannot seem to install the Cro successfully. I tried the dockerfile below: # Use the official ...
Seamus Brady's user avatar
7 votes
4 answers
304 views

"The Best Regex Trick" in Raku

The Best Regex Trick is about writing regexes that match r1 but not r2. The example they give is a regex that matches Tarzan (and "Tarzan and Jane") but not "Tarzan". After going ...
Hovercouch's user avatar
  • 2,312

15 30 50 per page
1
2 3 4 5
139