Boost logo

Boost :

From: Max Motovilov (max_at_[hidden])
Date: 2008-03-12 08:40:45


Larry Evans wrote:

> Input:
> list
> < list<A0_0, A0_1> //S1
> , list<A1_0, A1_1> //S2
> >
> Output:
> list
> < list<A0_0, A1_0> //s1[1]...S1[2]? Nope, this is S1[1]...S2[1]
> , list<A0_0, A2_0>
> , list<A0_1, A1_0>
> , list<A0_1, A1_1>
> >

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. 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.

...Max...


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