On Mon, May 27, 2013 at 09:24:28PM -0700, Timothee Cour wrote:
> > Done, turns out the fix was trivial, just swapping two static ifs:
> > https://github.com/D-Programming-Language/phobos/pull/1314
> 
> This isn't what Andrei had in mind in his post above:
> 
> > I'm disappointed cartesianProduct works that way; I should have
> > caught that during the code review. A better iteration order would
> > have spanned the lower position in both ranges first, i.e. create
> > squares of increasing side in the 2D space.
> 
> I would suggest an additional template parameter to specify the order
> of iteration:
[...]

The problem with allowing the user to specify order is that when one or
more of the input ranges are infinite, the order of traversal is much
less flexible, and it may not be possible to satisfy the requested
order.

The order that Andrei suggested is what's currently used for two
infinite ranges, though when finite ranges are involved I chose a
slightly simpler implementation. The order bearophile proposed in issue
9878 is different from what Andrei describes, at any rate.

What's the typical output order of cartesian products in other languages
/ libraries? It seems nobody can agree on what the order should be. :-/


T

-- 
People demand freedom of speech to make up for the freedom of thought
which they avoid. -- Soren Aabye Kierkegaard (1813-1855)

Reply via email to