Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132937 views
License: OTHER
1
object ThreeDice {
2
def main(arg: Array[String]) {
3
val dice_results = List(1, 2, 3, 4, 5, 6);
4
var outcomes = for(a <- dice_results;
5
b <- dice_results;
6
c <- dice_results)
7
yield a*b*c;
8
println("%d / %d".
9
format(
10
outcomes.filter(x => x % 2 == 1).length,
11
outcomes.length));
12
}
13
}
14