Anonymous user
99 Bottles of Beer/Scala: Difference between revisions
no edit summary
(Previous version failed with line spacing) |
No edit summary |
||
Line 1:
{{collection|99 Bottles of Beer}}
[[Category:Scala Implementations]]
The trivial solution to it would be this:▼
{{libheader|Scala}}
==The trivial solution==
▲The trivial solution to it would be this:
<lang scala>99 to 1 by -1 foreach { n =>
println(
Line 9 ⟶ 12:
f"${n - 1}%d bottles of beer on the wall\n")
}</lang>
===Running in parallel===
The above
▲<lang scala>(99 to 1 by -1).par foreach { n =>
println(
f"$n%d bottles of beer on the wall\n" +
Line 19 ⟶ 21:
f"${n - 1}%d bottles of beer on the wall\n")
}</lang>
▲A Regex solution:
▲<lang scala>object NinetyNineBottlesOfBeer {
val verse = """|99 bottles of beer on the wall
|99 bottles of beer
Line 43:
}
}</lang>
==A preferred ☺ sollution ==
▲<lang scala>object Song {
import scala.actors._
import scala.actors.Actor._
|