Anonymous user
List comprehensions: Difference between revisions
add E example
m (alphabetize) |
(add E example) |
||
Line 4:
Write a list comprehension that builds the list of all pythagorean triples with elements between 1 and n. If the language has multiple ways for expressing such a construct (for example, direct list comprehensions and generators), write one example for each.
=={{header|E}}==
pragma.enable("accumulator") # considered experimental
accum [] for x in 1..n { for y in x..n { for z in y..n { if (x**2 + y**2 <=> z**2) { _.with([x,y,z]) } } } }
=={{header|Erlang}}==
|