Skip to content

Instantly share code, notes, and snippets.

@Refefer
Created November 4, 2013 19:31
Show Gist options
  • Save Refefer/7307919 to your computer and use it in GitHub Desktop.
Save Refefer/7307919 to your computer and use it in GitHub Desktop.
def loopOver(xs: List[Int]) = {
val vs = xs.toStream
def loop(rem:Int):Stream[Stream[Int]] = rem match {
case 0 => for(v <- vs) yield Stream(v)
case n => for(head <- vs; tails <- loop(n-1)) yield head #:: tails
}
for(i <- Stream.from(0); items <- loop(i)) yield items
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment