Draw a sphere: Difference between revisions
Content added Content deleted
(Scala contribution added.) |
|||
Line 4,091: | Line 4,091: | ||
for (i <- math.floor(-r).toInt to Math.ceil(r).toInt; x = i + .5) { |
for (i <- math.floor(-r).toInt to Math.ceil(r).toInt; x = i + .5) { |
||
println( |
println( |
||
(for (j <- math.floor(-2 * r).toInt to Math.ceil(2 * r).toInt; |
(for (j <- math.floor(-2 * r).toInt to Math.ceil(2 * r).toInt; y = j / 2.0 + .5) |
||
y = j / 2.0 + .5) |
|||
yield if (x * x + y * y <= r * r) { |
yield if (x * x + y * y <= r * r) { |
||
Line 4,117: | Line 4,116: | ||
}</lang> |
}</lang> |
||
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/uSm8bJ9/0 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/TtVHUp3aS0eDEB6YCW4gKg Scastie (JVM)]. |
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/uSm8bJ9/0 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/TtVHUp3aS0eDEB6YCW4gKg Scastie (JVM)]. |
||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
{{trans|Perl 6}} |
{{trans|Perl 6}} |