RosettaCodeData/Task/List-comprehensions/CoffeeScript/list-comprehensions-1.coffee
2013-04-11 11:14:19 -07:00

10 lines
224 B
CoffeeScript

flatten = (arr) -> arr.reduce ((memo, b) -> memo.concat b), []
pyth = (n) ->
flatten (for x in [1..n]
flatten (for y in [x..n]
for z in [y..n] when x*x + y*y is z*z
[x, y, z]
))
console.dir pyth 20