Last active
April 4, 2016 23:48
-
-
Save Krasnyanskiy/bdf67fb45e9f76bad54621b5da2d812a to your computer and use it in GitHub Desktop.
-scala: foldr
This file contains hidden or 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
val words = List("a", "b", "c", "d", "a", "c", "b", "a", "b", "d") | |
val res0 = words.map(w => (w, 1)).foldRight(("", 1)) { | |
case ((x1, y1), (x2, y2)) => (x1 + x2, y1 + y2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment