Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Stem-and-leaf-plot/Scala/stem-and-leaf-plot.scala
Normal file
7
Task/Stem-and-leaf-plot/Scala/stem-and-leaf-plot.scala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def stemAndLeaf(numbers: List[Int]) = {
|
||||
val lineFormat = "%" + (numbers map (_.toString.length) max) + "d | %s"
|
||||
val map = numbers groupBy (_ / 10)
|
||||
for (stem <- numbers.min / 10 to numbers.max / 10) {
|
||||
println(lineFormat format (stem, map.getOrElse(stem, Nil) map (_ % 10) sortBy identity mkString " "))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue