On Tue, Oct 12, 2010 at 03:28, Simen kjaeraas <[email protected]> wrote: > Daniel Gibson <[email protected]> wrote: > >> (*) Something like >> Range!(Tuple!(T1, T2)) join(T1, T2)(Range!(T1) r1, Range!(T2) r2, >> BinaryPredicate!(T1, T2) joinPred) >> just pseudo-code, I'm not really familiar with D2 and std.algorithm. >> The idea is you have a Range r1 with elements of type T1, a Range r1 with >> elements of type T2 and a predicate that gets a T1 value and a T2 value and >> returns bool if they match and in that case a Tuple with those two values is >> part of the Range that is returned. > > Once again I see the combinatorial range in the background. Man, why does > this have to be so hard? > > That is, your join could be implemented as follows, given the > combinatorial product range combine: > > > auto join( alias fun, R... )( R ranges ) if ( allSatisfy!( isForwardRange, R > ) ) { > return filter!fun( combine( ranges ); > }
And IIRC, there is a difference between outer join, inner join and some other versions. So filter!fun(zip(ranges)) (that is, filtering in parallel) is also a possibilty. I should read some again on DB joints. There is also the need for creating a range of ranges on this one (aka, tensor product, but that scares people when I say that) Anyway, that's derailing the thread, so I'll stop now.
