Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread Don Clugston
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

Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread Andrei Alexandrescu
On 10/9/12 7:25 PM, H. S. Teoh wrote: I was an idiot. I knew about std.algorithm.joiner but for some reason didn't think of it at the time. In any case, crossProduct doesn't make any sense to me... I don't see what it's got to do with flattening nested ranges. I meant the resulting range spans

Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread H. S. Teoh
On Wed, Oct 10, 2012 at 09:41:34AM -0400, Andrei Alexandrescu wrote: On 10/9/12 7:25 PM, H. S. Teoh wrote: I was an idiot. I knew about std.algorithm.joiner but for some reason didn't think of it at the time. In any case, crossProduct doesn't make any sense to me... I don't see what it's got

Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread Andrei Alexandrescu
On 10/10/12 10:27 AM, H. S. Teoh wrote: On Wed, Oct 10, 2012 at 09:41:34AM -0400, Andrei Alexandrescu wrote: On 10/9/12 7:25 PM, H. S. Teoh wrote: I was an idiot. I knew about std.algorithm.joiner but for some reason didn't think of it at the time. In any case, crossProduct doesn't make any

Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread Andrei Alexandrescu
On 10/10/12 10:59 AM, Andrei Alexandrescu wrote: I'm still thinking of Cantor's method, just a different schedule of spanning the triangle. Multiple save points are necessary. I meant Multiple save points are NOT necessary. Andrei

Re: next_permutation and cartesian product for ranges?

2012-10-10 Thread H. S. Teoh
On Wed, Oct 10, 2012 at 10:59:32AM -0400, Andrei Alexandrescu wrote: On 10/10/12 10:27 AM, H. S. Teoh wrote: On Wed, Oct 10, 2012 at 09:41:34AM -0400, Andrei Alexandrescu wrote: [...] On another subject, I think this can be done with only input ranges - no need for bidirectional. [...] Using

next_permutation and cartesian product for ranges?

2012-10-09 Thread H. S. Teoh
Recently I've been working on some computational geometry code, and noticed that Phobos doesn't have any equivalent of STL's next_permutation. I saw there were some discussions about this back in 2010 -- did anything come of it? If there is any interest in next_permutation, I'd also like to

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Andrei Alexandrescu
On 10/9/12 1:52 PM, H. S. Teoh wrote: Recently I've been working on some computational geometry code, and noticed that Phobos doesn't have any equivalent of STL's next_permutation. I saw there were some discussions about this back in 2010 -- did anything come of it? If there is any interest in

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Jonathan M Davis
On Tuesday, October 09, 2012 14:25:13 Andrei Alexandrescu wrote: We need that badly. Please implement pronto and let us destroy you for having done so. Sounds violent. :) - Jonathan M Davis

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread H. S. Teoh
On Tue, Oct 09, 2012 at 02:25:13PM -0400, Andrei Alexandrescu wrote: On 10/9/12 1:52 PM, H. S. Teoh wrote: [...] If there is any interest in next_permutation, I'd also like to propose a next_even_permutation for ranges without duplicate elements. There is a simple way of extending Narayana

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Timon Gehr
On 10/09/2012 10:46 PM, H. S. Teoh wrote: On Tue, Oct 09, 2012 at 02:25:13PM -0400, Andrei Alexandrescu wrote: On 10/9/12 1:52 PM, H. S. Teoh wrote: [...] If there is any interest in next_permutation, I'd also like to propose a next_even_permutation for ranges without duplicate elements.

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread bearophile
Andrei Alexandrescu: Yes, we need next_permutation. It will be up to you to convince the Grand Inquisition Committee of Reviewers that next_even_permutation is necessary and/or sufficient. I don't like the design of C++ STL here. Instead of a next_permutation(), what about ranges that yield

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Timon Gehr
On 10/09/2012 11:23 PM, bearophile wrote: Andrei Alexandrescu: Yes, we need next_permutation. It will be up to you to convince the Grand Inquisition Committee of Reviewers that next_even_permutation is necessary and/or sufficient. I don't like the design of C++ STL here. Instead of a

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread ixid
struct Spermutations { The naming scheme could do with... improvement.

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread bearophile
ixid: The naming scheme could do with... improvement. struct PermutationSwaps then? Bye, bearophile

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Andrei Alexandrescu
On 10/9/12 4:46 PM, H. S. Teoh wrote: On Tue, Oct 09, 2012 at 02:25:13PM -0400, Andrei Alexandrescu wrote: On 10/9/12 1:52 PM, H. S. Teoh wrote: [...] If there is any interest in next_permutation, I'd also like to propose a next_even_permutation for ranges without duplicate elements. There is

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Steven Schveighoffer
On Tue, 09 Oct 2012 17:23:07 -0400, bearophile bearophileh...@lycos.com wrote: Andrei Alexandrescu: Yes, we need next_permutation. It will be up to you to convince the Grand Inquisition Committee of Reviewers that next_even_permutation is necessary and/or sufficient. I don't like the

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread bearophile
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

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread H. S. Teoh
On Tue, Oct 09, 2012 at 11:24:27PM +0200, Timon Gehr wrote: [...] That's cute. =) flatten is in std.algorithm and is called joiner. Ahahahaha... I knew joiner existed; why didn't I think of it. :P Also, you need to be careful with index types. I'd suggest: import std.algorithm,

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread H. S. Teoh
On Tue, Oct 09, 2012 at 05:46:41PM -0400, Andrei Alexandrescu wrote: On 10/9/12 4:46 PM, H. S. Teoh wrote: On Tue, Oct 09, 2012 at 02:25:13PM -0400, Andrei Alexandrescu wrote: On 10/9/12 1:52 PM, H. S. Teoh wrote: [...] If there is any interest in next_permutation, I'd also like to propose a

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread ixid
On Tuesday, 9 October 2012 at 22:06:42 UTC, bearophile wrote: ixid: The naming scheme could do with... improvement. struct PermutationSwaps then? Bye, bearophile I think you're missing what I meant, naming a struct Sperm-utations seemed a bit unpleasant, I'm not actually bothered about

Re: next_permutation and cartesian product for ranges?

2012-10-09 Thread Timon Gehr
On 10/10/2012 01:13 AM, H. S. Teoh wrote: On Tue, Oct 09, 2012 at 11:24:27PM +0200, Timon Gehr wrote: [...] That's cute. =) flatten is in std.algorithm and is called joiner. Ahahahaha... I knew joiner existed; why didn't I think of it. :P Also, you need to be careful with index types. I'd