Series Implementation I

I’d like to jump right in with work on the implementation of the new version of the series operator for Rakudo. It looks to me like this will end up being one of the most complicated functions in the Rakudo core, so I’m hoping this can be a good forum for discussing how to get all the details of it correct.

The basic idea here is that on the left side you’ve got zero or more list elements, maybe followed by a generating closure. On the right side, you have a limit value or possibly a Whatever to indicate going on forever (or until you hit the natural limit).

This sketchy initial version looks for the code block; if it finds it, it uses it. If it doesn’t find it, it attempts to generate one by analyzing the elements given in the list. It then iterates using the code block repeatedly, without any regard to the limit.

This doesn’t even do half of what the series operator is supposed to be able to do. Right now only arity-1 code blocks work — but any code block that generates values should work. And at the other end, the limit behavior can be pretty complex.

As I said, I’m hoping others can help me with this one. I’m pondering making a github project for it. But I don’t know at the moment how much of the project tools for Perl 6 actually work under the current Rakudo….