Interesting. I needed to generate some integer partitions myself for something I was working on the other day and I was surprised to discover that there wasn't anything already available on CPAN.
I searched around, and ran across the same paper. I imemplented both algorithms proposed by Zoghbi and Stojmenovic in that paper, to permit forward and reverse lexicographic orderings and released it as a module.
My only comment is that while your code is very consice, I think you have removed the constant average delay property that the original algorithm features. The algorithm only requires two scalars to maintain state, so it's not as if its a memory pig.
• another intruder with the mooring in the heart of the Perl
In reply to Re: Memoryless iterator for integer partitions
by grinder
in thread Memoryless iterator for integer partitions
by blokhead
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |