Skip to content
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

Adding head, skip, tail as subroutines #328

Closed
2colours opened this issue Jun 27, 2022 · 3 comments
Closed

Adding head, skip, tail as subroutines #328

2colours opened this issue Jun 27, 2022 · 3 comments
Labels
language Changes to the Raku Programming Language

Comments

@2colours
Copy link

Hello,
this has been mentioned on chat a couple of days ago.
It would be nice to have head, skip and tail as subroutines with the iterable as their last parameter, similarly to grep and map.
This would both increase consistency (why shouldn't they work, if grep and map do work?) and the usefulness off the feed operators, since this would allow us to write
1, 3 ... * ==> grep &some-condition ==> head 20
and similar code.

@2colours 2colours added the language Changes to the Raku Programming Language label Jun 27, 2022
lizmat added a commit to rakudo/rakudo that referenced this issue Jun 28, 2022
As requested in Raku/problem-solving#328

There is one biggish issue with this, as the sub "skip" clashes with
the "skip" sub as exported by Test.  Fixed this by giving the version
of "skip" from Test its own proto.

Since we added 3 more subs to the core, these tests all needed to be
adapted as well.
lizmat added a commit that referenced this issue Jun 28, 2022
@patrickbkr
Copy link
Member

@Smokemachine Is this related work of Reds respective operators? Do they match?

@lizmat
Copy link
Collaborator

lizmat commented Jun 28, 2022

I've also created a module to allow for this functionality in older Rakudo versions:

https://raku.land/zef:lizmat/head-skip-tail (aka https://github.com/lizmat/head-skip-tail)

lizmat added a commit to rakudo/rakudo that referenced this issue Jul 7, 2022
As requested in Raku/problem-solving#328

There is one biggish issue with this, as the sub "skip" clashes with
the "skip" sub as exported by Test.  Fixed this by giving the version
of "skip" from Test its own proto.

Since we added 3 more subs to the core, these tests all needed to be
adapted as well.
lizmat added a commit that referenced this issue Jul 7, 2022
@lizmat
Copy link
Collaborator

lizmat commented Jul 11, 2022

This has been merged, so closing this issue.

@lizmat lizmat closed this as completed Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language Changes to the Raku Programming Language
Projects
None yet
Development

No branches or pull requests

3 participants