Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-03-12 09:13:43


On 03/12/08 07:40, Max Motovilov wrote:
> Larry Evans wrote:
[snip]
> Not quite like that, and I knew my "description" would end up being
> misleading :( -- so much for posting after a long working day.
>
> Input:
>
> list<
> list< A0_0, A0_1 >,
> list< A1_0, A1_1 >
> >
>
> Output:
>
> list<
> list< A0_0, A1_0 >,
> list< A0_0, A1_1 >,
> list< A0_1, A1_0 >,
> list< A0_1, A1_1 >
> >
>
> I think this is what you meant to write above.

Yep. Hadn't had my first cup coffee yet ;)

> Yes, it is an outer
> product, or direct product, or Cartesian product:
> C(A,B)={ [x,y] | for each x in A and y in B }
>
> And of course if any of the sequences is empty, the output is also
> empty. Requires a separate rule, incidentally.

In that case, then yes, it's been at least considered. The
_C++ Template Metaprogramming_ book has it as an exercise,
exercise 7-8 and calls it crossproduct_view.
A solution is posted here:

http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?CPPTM_Answers_-_Exercise_7-8

It would be interesting to compare the two solutions. The exercise just
specified 2 input sequences whereas your's allows (I guess)
any n>0 number of input sequences.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk