On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu < seewebsiteforem...@erdani.org> wrote:
> > equivalent to the problem: >> >> auto solution = comp!("[a,b]", "a*b == 8")([1,2,3], [4,5,6]); >> >> solution is a range, in this case a one element range, containing only >> [2,4]. >> > I did a range comprehension maybe one year ago, which would be partially > > Here we need to have a crossProduct range, as we discussed in the thread > "Combining infinite ranges". Then it's easy to combine it with filter: > > auto solutions = filter!"a*b == 8"(crossProduct([1,2,3], [4,5,6])); Not exactly: crossProduct is a range, and the only element type that makes sense is Tuple!(A,B). Unless of course you're interested in adding binary predicates to filter, which would be understood as automatically opening tuples (and of course, would statically check the length of the tuple and the arity of the passed function). I can add this to Phobos. What you call crossProduct can be seen as zipWith!tuple(range, range2), which If there is interest in this, I also suggest having a n-range version of map that takes a n-ary function and maps them in parallel. auto m = map!"a < b ? a : c"(range1, range2, range3); OK, I definitely need to take some time to assemble all this and propose it for a formal Phobos review. I'll bump it up higher in my TODO list. Philippe Philippe