-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how do you run Perl functions that take blocks as arguments? #161
Comments
In Raku, there's no implicit comma after a block. You need to actually write out |
Sure, that was the first thing I tried.. However:
Result:
It should find the |
Perhaps Array::Sorted::Util can be of use? |
Oh, I don't doubt it. I can also But this doesn't quite resolve the matter generally: there are a great many functions all over the place in
(e.g. reduce, first, etc. etc.). I would still like to know what the best way is to render those in
complains without the comma because it's not there, and with the comma because of a
|
Basically what's needed here is mapping Raku's $_ to Perl's. That should be
quite possible as $_ is available to XS code as UNDERBAR. It will cost a bit
of performance though as we'll have to set this up for every call, since we
don't know whether it's needed or not.
However that's not yet implemented. But until it is, one can access Perl's $_
directly:
```
use List::Util:from<Perl5> <first>;
say first { %*PERL5<$_> %% 3 }, 1, 2, 3, 4
```
Unfortunately I found a bug when trying this. Notice the absence of
parenthesis in my example? That's because it'd pass the whole list as a single
item to first otherwise. It works as expected when calling fully qualified
though:
```
use List::Util:from<Perl5>;
say List::Util::first { %*PERL5<$_> %% 3 }, (1, 2, 3, 4)
```
|
That worked, thank you! I'm glad I asked :). |
On Mon, May 3, 2021 at 13:07 stuart-little ***@***.***> wrote:
That worked, thank you! I'm glad I asked :).
And if you could put that in the README that would be great! I look forward
to trying it out.
|
I am trying to do this:
as per that module's docs. The result in
Raku
:The text was updated successfully, but these errors were encountered: