Created
December 4, 2011 04:54
-
-
Save tyano/1429218 to your computer and use it in GitHub Desktop.
List(1, 2, 3, 1) を Map(1 -> 2, 2 -> 1, 3 -> 1) No.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List(1,2,3,1).foldLeft(Map[Int,Int]()) { (x, y) => x.get(y) match { case Some(v) => x + Pair(y, (v + 1)) case None => x + Pair(y, 1) }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment