Boost logo

Boost :

Subject: Re: [boost] [MPL] new run-time algorithm: for_all
From: Larry Evans (cppljevans_at_[hidden])
Date: 2008-11-22 19:34:05


On 11/22/08 07:59, Joe Gottman wrote:
> George van Venrooij wrote:
>> Hello everyone,
>>
>> I recently created a MPL-based run-time algorithm named "for_all"
>> which you can find at the following location:
>>
>> http://tinyurl.com/5a9d9d
>>
>> It is based on the "for_each" algorithm. The main difference is that
>> it traverses a sequence of sequences and constructs new sequences that
>> are then passed to a functor. Read the article for more information.
[snip]
> 1) The name isn't informative. How about something like
> mpl::all_combinations to better say what the function actually does?
>
> 2) You should mention in the documentation that the number of
> sequences returned can get very big very fast. For instance, given six
> input sequences with 10 elements each, this function will return 1
> million sequences of 6 elements each.

 From Joe's comment, it sounds like for_all is the same as
the answer to exercise 7-8 of:

   http://www.boostpro.com/mplbook/

So, a better name, IMHO, would be something with cross_product in the
name, or maybe cartesian_product or outer_product. IIRC, outer_product
is what apl calls that operation.

Anyway, I've posted an answer to exercise 7-8 at:

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

Currently, I'm learning haskell, and they have a way, using a list
monad, to do the same, AFAICT. See:

   http://www.muitovar.com/monad/moncow.xhtml#list

There, the function is called cross.

IIRC, FC++ or someone connected with FC++:

   http://sourceforge.net/projects/fcpp/

has a monad template. It would be interesting to try
and use a c++ list monad to solve the problem. I'll
probably try it eventually, but maybe someone else
would like to try. Who knows, a monad solution may
have some advantage.


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