Skip to content

Instantly share code, notes, and snippets.

@markhibberd
Created February 11, 2014 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markhibberd/8927938 to your computer and use it in GitHub Desktop.
Save markhibberd/8927938 to your computer and use it in GitHub Desktop.
def dsortNat[A](z: NatOrd, xs: Stream[(Int,A)]): Stream[Stream[A]] = {
val arr = new Array[MutableList[A]](z.i+1)
xs.foreach { arg: (Int,A) =>
val idx = arg._1
if(arr(idx) == null) arr(idx) = MutableList[A](arg._2)
else arr(idx) += arg._2
}
arr.toStream.filter(_ != null).map(_.toStream)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment