Created
February 11, 2014 01:56
-
-
Save markhibberd/8927938 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
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