Anonymous user
Sorting Algorithms/Circle Sort: Difference between revisions
→{{header|Haskell}}: Changed Haskell implementation, removed monadic stuff, and cleaned
(→{{header|Haskell}}: Updated Haskell code) |
(→{{header|Haskell}}: Changed Haskell implementation, removed monadic stuff, and cleaned) |
||
Line 983:
This code uses the tortoise-and-the-hare technique to split the input list in two and compare the relevant positions.
<lang haskell>import Data.
circleSort :: Ord a => [a] -> [a]
circleSort xs = if swapped then circleSort
where
(
go d []
go d [x] (s,ks) =
go d xs
let (s',_,ls,rs)
halve d s (y:ys) (_:_:zs) =
halve d s ys [] =
halve d s (y:ys) [_] =
where
| bool (<=) (<) d x y = (
| otherwise =
{{out}}
|