List comprehensions: Difference between revisions

Content added Content deleted
m (→‎{{header|C}}: 3 syntaxhighlight -> 1 plus comment)
m (→‎{{header|CoffeeScript}}: 2*syntaxhighlight -> 1 plus comment)
Line 604: Line 604:
[x, y, z]
[x, y, z]
))
))
# pyth can also be written more concisely as
# pyth = (n) -> flatten (flatten ([x, y, z] for z in [y..n] when x*x + y*y is z*z for y in [x..n]) for x in [1..n])


console.dir pyth 20</syntaxhighlight>
console.dir pyth 20</syntaxhighlight>

<code>pyth</code> can also be written more concisely as

<syntaxhighlight lang="coffeescript">pyth = (n) -> flatten (flatten ([x, y, z] for z in [y..n] when x*x + y*y is z*z for y in [x..n]) for x in [1..n])</syntaxhighlight>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==