------------------------------
Message: 2
Date: Tue, 20 Dec 2011 21:45:26 +0100
From: Philippe Sigaud <philippe.sigaud@gmail.com>
To: "digitalmars.D.learn" <digitalmars-d-learn@puremagic.com>
Subject: Re: newbie question: Can D do this?
Message-ID:
<CAOA6Bi6BaYm1T3PhvWY9mBRPsedK_dDjWYr-7yDO5cOV2ddiTw@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Mon, Dec 19, 2011 at 17:17, clk <clk@clksoft.com> wrote:
Correct. As other have said, it's doable by combining std functions.
As fas as I know, we do not have a cartesian product range, to iterate
on all combinations of two or more ranges.
[f(x,y) for x in list1 for y in list2 if condition]
I gave it a try a few years ago and could get something like this:
auto lc = comp!("tuple(a,b,c)", "a*a+b*b == c*c && a<b")(input1,
input2, input3);
-> mapper, condition,
input ranges, as many as you wish
But at the time I couldn't find a way to do bindings, that is:
[f(x,y) for x in [0..10] for y in [0..x]]
-> the range iterated by y depends on x.
If anyone has an idea, I'm game.
Philippe