How can I create a tuple where each of the members are compared by an expression? <p>Well, here is the thing:</p> <p>I have the following Haskell code, this one:</p> <pre><code>[ (a, b, c) | c &lt;- [1..10], b &lt;- [1..10], a &lt;- [1..10], a ^ 2 + b ^ 2 == c ^ 2 ] </code></pre> <p>Which will returns</p> <pre><code>[(4,3,5),(3,4,5),(8,6,10),(6,8,10)] </code></pre> <p>For those who aren't familiar with this, I'll explain:</p> <ul> <li>It returns a <code>tuple</code> (a,b,c), where each of these "definitions" (a,b,c) receive a list (1 up to 10) and his members are compared by the <code>a ^ 2 + b ^ 2 == c ^ 2 ?</code> expression (each member).</li> </ul> <p><strong>How can I do the same (one line if possible) in Python/Ruby?</strong></p> <p>P.S.: <em>they are compared in lexicographical order.</em></p>