Philippe,
I don't understand the example below to simulate the list comprehension
syntax. Are input1, input2 and input3 ranges? Where is the comp
function defined?
Thank you,
-clk
(Christian Keppenne)
auto lc = comp!("tuple(a,b,c)", "a*a+b*b == c*c&& a<b")(input1,input2, input3);
------------------------------
Message: 2
Date: Tue, 20 Dec 2011 21:45:26 +0100
From: Philippe Sigaud<philippe.sig...@gmail.com>
To: "digitalmars.D.learn"<digitalmars-d-learn@puremagic.com>
Subject: Re: newbie question: Can D do this?
Message-ID:
<caoa6bi6baym1t3phvwy9mbrpsedk_ddjwyr-7ydo5cov2dd...@mail.gmail.com>
Content-Type: text/plain; charset=UTF-8
On Mon, Dec 19, 2011 at 17:17, clk<c...@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