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

roundrobin needs a metaoperator #447

Open
lizmat opened this issue Oct 10, 2024 · 3 comments
Open

roundrobin needs a metaoperator #447

lizmat opened this issue Oct 10, 2024 · 3 comments
Labels
language Changes to the Raku Programming Language

Comments

@lizmat
Copy link
Collaborator

lizmat commented Oct 10, 2024

This seems obvious, but I did not see another issue relating to it.

zip's infix and metaoperator, Z is tremendously valuable, but it is extremely common to run up against the need to drop down to using roundrobin because the input does not contain equally sized lists. One such example came up today on reddit here:

https://old.reddit.com/r/perl6/comments/c2hw1u/some_code_golf_help_requested/erkzbh1/

The obvious approach in that case would be to reverse the lists of digits, roundrobin add them and then re-join them in a single number.

Assuming we had a roundrobin infix and metaoperator , this would change the code:

+ [~] [Zmax] context-pad(@nums).map: {.comb }

to:

+ flip [~] [➿max] @nums.map: {.flip.comb }

Which isn't simply code-golfing, but actually obviates the need for the context-pad step that zero-pads all of the input numbers.

Expected Behavior

zip and roundrobin are equal peers.

Actual Behavior

They are not.

@lizmat lizmat added the language Changes to the Raku Programming Language label Oct 10, 2024
@lizmat
Copy link
Collaborator Author

lizmat commented Oct 10, 2024

Lifted from rakudo/rakudo#3002

@librasteve
Copy link

librasteve commented Oct 15, 2024

I really like this idea.

I am not sure of the loopy unicode symbol. Other metas are capital Latin letters R and Z. Since R is taken maybe O would be good (Since O is round)

Would you be able to combine eg RO? What would be the effect of combining this with Z?

@jubilatious1
Copy link

Roundrobin is simply Z that pads.

So the real question is whether a metaoperators can be re-jiggered to accept named arguments, such as:

[Z:pad("right"),:char("NA")]   @arrayA, @arrayB

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