Created
October 19, 2013 00:22
-
-
Save MansurAshraf/7050203 to your computer and use it in GitHub Desktop.
word pair
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
| object WordPair { | |
| def main(args: Array[String]) = { | |
| val line = "Android is a Linux-based operating system designed primarily for touchscreen mobile devices".split(" ").toList | |
| val pairs = wordPair(line) | |
| println(pairs) | |
| } | |
| def wordPair(line: List[String]): List[(String, String)] = line match { | |
| case Nil => Nil | |
| case x :: Nil => Nil | |
| case x :: y :: tail => (x, y) :: wordPair(y :: tail) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment