List comprehensions: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|C}}: 3 syntaxhighlight -> 1 plus comment)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(3 intermediate revisions by one other user not shown)
Line 21:
{{trans|Python}}
 
<syntaxhighlight lang="11l"> print(cart_product(1..20, 1..20, 1..20).filter((x, y, z) -> x ^ 2 + y ^ 2 == z ^ 2 & y C x .. z))</syntaxhighlight>
 
{{out}}
Line 275:
end mReturn</syntaxhighlight>
{{Out}}
<syntaxhighlight lang="applescript"pre>{{3, 4, 5}, {5, 12, 13}, {6, 8, 10}, {7, 24, 25}, {8, 15, 17}, {9, 12, 15}, {12, 16, 20}, {15, 20, 25}}</syntaxhighlightpre>
 
=={{header|Arturo}}==
Line 604:
[x, y, z]
))
<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>
 
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}}==
Line 2,709 ⟶ 2,707:
=={{header|Wren}}==
Using a generator.
<syntaxhighlight lang="ecmascriptwren">var pythTriples = Fiber.new { |n|
(1..n-2).each { |x|
(x+1..n-1).each { |y|
9,482

edits