[Haskell-cafe] Re: howto tuple fold to do n-ary cross product?

Larry Evans cppljevans at suddenlink.net
Mon Dec 1 10:43:22 EST 2008


On 11/30/08 12:49, Larry Evans wrote:
[snip]
> 
> You'll see Domains can be an mpl::vector of any
> length. The cross_nproduct_view_test.cpp tests
> with a 3 element Domains:
> 
>         typedef
>       mpl::vector
>       < mpl::range_c<int,0,4>
>       , mpl::range_c<int,100,103>
>       , mpl::range_c<int,2000,2002>
>       >
>     domains;

OOPS.  That's in another test driver.  The one
in the cross_nproduct_view_test.cpp has:

     typedef range_c<int,    0,    1> seq0;
     typedef range_c<int,  100,  102> seq1;
     typedef range_c<int, 2000, 2002> seq2;
     typedef range_c<int,30000,30003> seq3;
         typedef
       list
       < seq0
       , seq1
       , seq2
       , seq3
       >
     domains;

The range_c<int, 100, 102> template instance:

http://www.boost.org/doc/libs/1_37_0/libs/mpl/doc/refmanual/range-c.html

produces a type sequence of length 2.
So mpl::list<seq0,...,seq3> is a sequence of sequences
similar to haskell's [[a]] except that it's a sequence
of a sequences of types instead of a sequence of
sequences of values.

> 
> The cross_nproduct_view template  and test driver
> are found in the cross_nproduct_view.zip file here:
> 
>   http://preview.tinyurl.com/5ar9g4



More information about the Haskell-Cafe mailing list