Subject: Re: [boost] Proposed addition to the iterator library for iterating over all tuples.
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-06-16 15:38:35
On 08/01/05 03:41, Alex Mendes da Costa wrote:
> Quick update: I currently have a partial (but working) implementation
> of the cross_iterator. I hope to have a preliminary submission ready
> some time this week.
> On 7/26/05, David Abrahams <dave_at_[hidden]> wrote:
>> Alex Mendes da Costa <alexmdac_at_[hidden]> writes:
>>> The iterator that I am proposing would provide the sequence (1,10),
>>> (2,10), (1,20), (2,20).
>> Oh, you want a cross-product iterator. Interesting idea.
A haskell list comprehension is what you need, AFAICT.
FC++ can do this, if I'm correctly interpreting pages 16,19-20 of:
For example, p. 19 uses (in haskell syntax):
[x+y|x <- [1,2,3], y <- [2,3], x<y]
(as shown on p. 16), and the corresponding FC++:
[ X %plus% Y
| X <= list_with(1,2,3)
, Y <= list_with(2,3)
, guard[X %less% Y]
is shown just below the haskell code on p. 19.
In your case, I guess the X %plus% Y would maybe be replaced with
some sort of mpl sequence, e.g. mpl::list<X,Y>, and for more than
2 domans, I'd guess you'd have to have:
Also, maybe FC++ could be adapted to make this easier. Hmm..
maybe mpl::fold could be combined with compM to do this for
any number of domains.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk