List comprehensions: Difference between revisions
Content added Content deleted
No edit summary |
(Added Wren) |
||
Line 2,536: | Line 2,536: | ||
=={{header|Wrapl}}== |
=={{header|Wrapl}}== |
||
<lang wrapl>ALL WITH x <- 1:to(n), y <- x:to(n), z <- y:to(n) DO (x^2 + y^2 = z^2) & [x, y, z];</lang> |
<lang wrapl>ALL WITH x <- 1:to(n), y <- x:to(n), z <- y:to(n) DO (x^2 + y^2 = z^2) & [x, y, z];</lang> |
||
=={{header|Wren}}== |
|||
Using a generator. |
|||
<lang ecmascript>var pythTriples = Fiber.new { |n| |
|||
(1..n-2).each { |x| |
|||
(x+1..n-1).each { |y| |
|||
(y+1..n).each { |z| (x*x + y*y == z*z) && Fiber.yield([x, y, z]) } |
|||
} |
|||
} |
|||
} |
|||
var n = 20 |
|||
while (!pythTriples.isDone) { |
|||
var res = pythTriples.call(n) |
|||
res && System.print(res) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
[3, 4, 5] |
|||
[5, 12, 13] |
|||
[6, 8, 10] |
|||
[8, 15, 17] |
|||
[9, 12, 15] |
|||
[12, 16, 20] |
|||
</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |