next_permutation and cartesian product for ranges?

Don Clugston dac at nospam.com
Wed Oct 10 01:53:57 PDT 2012


On 10/10/12 00:22, bearophile wrote:
> Steven Schveighoffer:
>
>> Is there any advantage over having a function?  I'd think you could
>> easily build a range based on the function, no?
>
> Generators (that yield lexicographic permutations, permutation swaps,
> combinations, etc) are quite more handy, you can compose them with the
> other ranges and higher order functions.

> Adding to Phobos few ranges that build on a next_permutation(),
> next_combination(), etc, is possible, but I don't see a big need for
> such C++-style functions, the ranges are enough.

What makes you think that permutations are only ever used in a range 
context? Do you have any evidence for that?

Sounds like an abstraction inversion to me.




More information about the Digitalmars-d mailing list