Skip to content

Instantly share code, notes, and snippets.

@dwins
Created September 27, 2012 18:25
Show Gist options
  • Select an option

  • Save dwins/3795548 to your computer and use it in GitHub Desktop.

Select an option

Save dwins/3795548 to your computer and use it in GitHub Desktop.
def powerSet[A](xs: List[A]): List[List[A]] =
xs.foldLeft(List(Nil: List[A]))((accum, elem) => accum.flatMap(l => Seq(l, elem :: l)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment