Created
July 4, 2014 09:05
-
-
Save johnelf/de7641ba035b9f63f28b to your computer and use it in GitHub Desktop.
循环赛
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
type SoccerFixtures = List[(String, String)] | |
def doCombine(teams: List[String], res: SoccerFixtures): SoccerFixtures = teams match { | |
case Nil => res | |
case pick :: others => | |
doCombine(others, others.map(o => (pick, o)) ::: res) | |
} | |
doCombine(List("a", "b", "c", "d"), List()).sorted | |
def combine(teams: List[String]) = doCombine(teams, List()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment