Skip to content

Instantly share code, notes, and snippets.

@johnelf
Created July 4, 2014 09:05
Show Gist options
  • Save johnelf/de7641ba035b9f63f28b to your computer and use it in GitHub Desktop.
Save johnelf/de7641ba035b9f63f28b to your computer and use it in GitHub Desktop.
循环赛
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