problem-solving icon indicating copy to clipboard operation
problem-solving copied to clipboard

roundrobin needs a metaoperator

Open lizmat opened this issue 1 year ago • 2 comments

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 avatar Oct 10 '24 11:10 lizmat