List comprehensions: Difference between revisions

Content added Content deleted
(Added Scala)
(added C# implementation)
Line 41: Line 41:
+3 +4 +5 +5 +12 +13 +6 +8 +10 +8 +15 +17 +9 +12 +15 +12 +16 +20
+3 +4 +5 +5 +12 +13 +6 +8 +10 +8 +15 +17 +9 +12 +15 +12 +16 +20
</pre></div>
</pre></div>

=={{header|C#}}==
<lang csharp>using System.Linq;

static class Program
{
static void Main()
{
var ts =
from a in Enumerable.Range(1, 20)
from b in Enumerable.Range(a, 21 - a)
from c in Enumerable.Range(b, 21 - b)
where a * a + b * b == c * c
select new { a, b, c };

foreach (var t in ts)
System.Console.WriteLine("{0}, {1}, {2}", t.a, t.b, t.c);
}
}
</lang>


=={{header|C++}}==
=={{header|C++}}==