Why is `scope` planned for deprecation?
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 20 17:27:31 PST 2014
On Friday, 21 November 2014 at 01:09:27 UTC, Walter Bright wrote:
> Except that isn't really quicksort. Monads are the workaround
> functional languages use to deal with things that need mutation.
Yes, at least in Haskell, but I find monads in Haskell harder to
read than regular imperative code. You can apparently cheat a
little using libraries, this doesn't look too bad (from slashdot):
import qualified Data.Vector.Generic as V
import qualified Data.Vector.Generic.Mutable as M
qsort :: (V.Vector v a, Ord a) => v a -> v a
qsort = V.modify go where
go xs | M.length xs < 2 = return ()
| otherwise = do
p <- M.read xs (M.length xs `div` 2)
j <- M.unstablePartition (< p) xs
let (l, pr) = M.splitAt j xs
k <- M.unstablePartition (== p) pr
go l; go $ M.drop k pr
http://stackoverflow.com/questions/7717691/why-is-the-minimalist-example-haskell-quicksort-not-a-true-quicksort
More information about the Digitalmars-d
mailing list