[Haskell-cafe] Re: howto tuple fold to do n-ary cross product?
cppljevans at suddenlink.net
Sun Nov 30 13:49:29 EST 2008
On 11/30/08 12:27, Luke Palmer wrote:
> On Sun, Nov 30, 2008 at 11:04 AM, Larry Evans <cppljevans at suddenlink.net> wrote:
>> The following post:
>> shows at least one person that would find it useful, at least in
>> c++. Of course maybe it would be less useful in haskell.
> The line:
> typedef boost::mpl::vector <T1Variants, T2Variants, T3Variants> TT;
> Has the number of lists hard-coded as 3, and does not abstract over
> it. This corresponds to the "3" in "liftA3", or the number of <*>s in
> the expression.
> Abstracting over the number and types of arguments is something
> neither C++ nor Haskell is very good at. But in order to be able to
> do any abstraction using such a variable-argument function, the type
> systems of these languages would have to increase in complexity by
> quite a lot.
True, but if you look at the cross_nproduct_view template:
< class Domains
, cross_product_view<arg<2>,arg<1> >
You'll see Domains can be an mpl::vector of any
length. The cross_nproduct_view_test.cpp tests
with a 3 element Domains:
The cross_nproduct_view template and test driver
are found in the cross_nproduct_view.zip file here:
More information about the Haskell-Cafe