Created
August 20, 2014 16:48
-
-
Save fmap/59c08056e233925d0275 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
import Prelude hiding (span, head, null) | |
import Control.Monad (liftM2) | |
import Data.Vector (Vector, null, empty, cons, span, head, thaw, freeze) | |
import qualified Data.Vector.Algorithms.Intro as Intro (sort) | |
group :: Eq a => Vector a -> Vector (Vector a) | |
group vs | null vs = empty | |
| otherwise = a `cons` group b where (a, b) = span (== head vs) vs | |
sort :: Ord a => Vector a -> IO (Vector a) | |
sort vs = thaw vs >>= liftM2 (>>) Intro.sort freeze |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment