List comprehensions: Difference between revisions

→‎{{header|SuperCollider}}: modernized and simplified syntax
m (→‎{{header|Sidef}}: minor code simplifications)
(→‎{{header|SuperCollider}}: modernized and simplified syntax)
Line 1,895:
 
=={{header|SuperCollider}}==
<lang supercollider>var pyth = {
// 10 is the default value of the argument
arg n = 10; // default
var pyth = { |n = 10|
all {: [x,y,z],
x <- (1..n),
Line 1,902 ⟶ 1,903:
z <- (y..n),
(x**2) + (y**2) == (z**2)
};
};
 
pyth.value(20); // example call</lang>
returns
<lang supercollider>[ [ 3, 4, 5 ], [ 5, 12, 13 ], [ 6, 8, 10 ], [ 8, 15, 17 ], [ 9, 12, 15 ], [ 12, 16, 20 ] ]</lang>
83

edits