2,094 questions
Score of 1
1 answer
104 views
Why does "so all( )" return True?
I have this output in my Raku REPL:
[5] > so all()
True
Empty lists should evaluate to False, and all False should be False.
So, why does it return True?
What I wanted was to have all items in an ...
Score of 0
1 answer
155 views
Does Raku have an SDK related to Anthropic?
Does Raku have an SDK related to Anthropic? I see that Ruby and Python both have officially maintained SDKs: anthropic-sdk-ruby and anthropic-sdk-python.
Score of 4
2 answers
189 views
Why doesn't this look-behind assertion with a predefined regular expression work as expected?
Why do the third and fourth substitutions produce different results?
#!/usr/bin/env raku
use v6.d;
my $str;
my regex myregex1 { <[\d;]>+ };
$str = "abc3def0ghi";
$str.=subst( / <?...
Score of 2
1 answer
169 views
In Raku, how to assign a value but only if the value is defined?
I want to assign
my $FOO = $foo if $foo.defined;
I tried
my $FOO with= $foo;
but that doesn't work. Is there a canonical way to do this?
Score of 1
2 answers
169 views
In Raku, how to import a module during runtime?
I would like to import Test::Color only when %*ENV<TEST_COLOR> is set.
I can't put use inside an if block, because use happens at compile time. I put require inside the if block, to no effect.
...
Score of -4
2 answers
226 views
Raku solution for discovering words for word puzzle [closed]
I would like to develop a raku script that can search a word list for words of the same length which contain the same characters except for one. For example 'castle' and 'cattle' would be appropriate ...
Score of 0
2 answers
62 views
Two level export in Raku
I have a tree of modules Air::Base, Air::Base::Tools and so on, and I want to re-export the Air::Base::Tools enum from Air::Base to code that uses that.
Air::Base::Tools rakumod…
sub exports-air-base-...
Score of 5
1 answer
140 views
get method objects using only spec'd features
Using only features from the Raku specification, i.e., not using any implementation-specific features, is there a way to get the method objects for a given class / object?
I'd like to do something ...
Score of 6
1 answer
139 views
Too many positionals passed error with slurpy hash
I'm trying to understand this behavior/error message. If I pass a pair where the key is unquoted to a slurpy hash, it succeeds. If I pass a pair where the key is explicitly quoted to a slurpy hash I ...
Score of 0
2 answers
141 views
How can I unconditionally evaluate two terms and return the first one evaluated?
Sometimes, I write code like
my $x = do {
my $result = get-result;
do-a-thing-that-would-change-result;
$result
};
. Whenever I do, I yearn for an operator to express this idea. You ...
Score of 5
1 answer
106 views
Initializing required attributes without BUILD submethod
In Raku, is it, or will it ever be possible to set required private attributes without writing a BUILD submethod?
E.g., the following does not work:
class C {
has Str:D $!name is required;
}
C.new:...
Score of 7
2 answers
257 views
How to use the raku operator 'ff'or 'fff' in a 'for lines()' loop
Given the input file:
----------------
A
----------------
information for A
on these lines
----------------
B
----------------
Something about B
on these lines
etc
I want to produce:
A: information ...
Score of 2
1 answer
144 views
Why is the deep cloned object still linked?
Following the documentation and this SO answer I wrote the following class with clone method, but the tests in the code do not give the expected result.
use v6.d;
use Test;
class Numeration {
...
Score of 3
2 answers
178 views
How to create a CL utility with an option set?
Background:
In build.rakumod I have several multi sub MAIN( ... ), one of which is:
multi sub MAIN(
:$config = 'config', #= localised config file
Bool :install($)!, #= install a config ...
Score of 5
1 answer
183 views
Unable to print color when color code is taken from array
I have color codes stored in an array. I cannot print color when I take a color code from the array, but I can print color if I use the code directly in a "say" or "print" ...