<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#cccccc">
    Philippe,<br>
    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?<br>
    Thank you,<br>
    -clk<br>
    (Christian Keppenne)<br>
    <pre wrap="">auto lc = comp!("tuple(a,b,c)", "a*a+b*b == c*c && a<b")(input1,input2, input3);</pre>
     
    <br>
    <blockquote
cite="mid:mailman.6869.1324482902.24801.digitalmars-d-learn@puremagic.com"
      type="cite">
      <pre wrap="">
------------------------------

Message: 2
Date: Tue, 20 Dec 2011 21:45:26 +0100
From: Philippe Sigaud <a class="moz-txt-link-rfc2396E" href="mailto:philippe.sigaud@gmail.com"><philippe.sigaud@gmail.com></a>
To: "digitalmars.D.learn" <a class="moz-txt-link-rfc2396E" href="mailto:digitalmars-d-learn@puremagic.com"><digitalmars-d-learn@puremagic.com></a>
Subject: Re: newbie question: Can D do this?
Message-ID:
        <a class="moz-txt-link-rfc2396E" href="mailto:CAOA6Bi6BaYm1T3PhvWY9mBRPsedK_dDjWYr-7yDO5cOV2ddiTw@mail.gmail.com"><CAOA6Bi6BaYm1T3PhvWY9mBRPsedK_dDjWYr-7yDO5cOV2ddiTw@mail.gmail.com></a>
Content-Type: text/plain; charset=UTF-8

On Mon, Dec 19, 2011 at 17:17, clk <a class="moz-txt-link-rfc2396E" href="mailto:clk@clksoft.com"><clk@clksoft.com></a> wrote:

</pre>
      <pre wrap="">
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
</pre>
    </blockquote>
    <br>
  </body>
</html>