99 Bottles of Beer/Scala: Difference between revisions
m
Fixed syntax highlighting.
m (Rm Scala imp category) |
m (Fixed syntax highlighting.) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1:
{{collection|99 Bottles of Beer}}
<span style='font-family: "Linux Libertine",Georgia,Times,serif;font-size:150%;'>[[Scala]]</span><hr>
===The trivial solution===
The trivial solution to it would be this:
<
println(
f"$n%d bottles of beer on the wall\n" +
Line 10:
f"Take one down, pass it around\n" +
f"${n - 1}%d bottles of beer on the wall\n")
}</
===Running in parallel===
The above n parallel using a ParRange, fast but shuffles the output.
<
println(
f"$n%d bottles of beer on the wall\n" +
Line 19 ⟶ 20:
f"Take one down, pass it around\n" +
f"${n - 1}%d bottles of beer on the wall\n")
}</
===Regex solution===
<
val verse = """|99 bottles of beer on the wall
|99 bottles of beer
Line 41 ⟶ 43:
changeLine(line)
}
}</
===A preferred ☺
<lang Scala>object Song {▼
<syntaxhighlight lang="scala">// Note - As Of Scala 2.11.0 The 'Scala Actors' Library Has Been Deprecated In Favor Of Akka.
import scala.actors._
import scala.actors.Actor._
Line 135 ⟶ 139:
Patrons ! SingSong(Beer)
}
}</
|