Manifest version of quicksort
Modulemassiv-1.0.5.0Haskell2010
Data.Massiv.Array.Mutable.Algorithms
- 4 values
- Packagemassiv-1.0.5.0
- Exports4
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceSort.hs
Same as quicksortM_, but instead of Ord constraint expects a custom Ordering.
unstablePartitionM Partition elements of the supplied mutable vector according to the predicate.
Example
import Data.Massiv.Array as Aimport Data.Massiv.Array.Mutable.Algorithms:set -XOverloadedListsm <- thaw ([2,1,50,10,20,8] :: Array P Ix1 Int)unstablePartitionM m (pure . (<= 10))4freeze Seq mArray P Seq (Sz1 6) [ 2, 1, 8, 10, 20, 50 ]
iterateUntilM :: (Load r' ix e, Manifest r e, MonadIO m)=> (Int -> Array r ix e -> MArray RealWorld r ix e -> m Bool)Convergence condition. Accepts current iteration counter, pure array at previous state and a mutable at the current state, therefore after each iteration its contents can be modifed if necessary.
-> (Int -> Array r ix e -> m (Array r' ix e))A modifying function to apply at each iteration. The size of resulting array may differ if necessary.
-> Array r ix eInitial source array
-> m (Array r ix e)
Monadic version of iterateUntil where at each iteration mutable version of an array is available. However it is less efficient then the pure alternative, because an intermediate array must be copied at each iteration.