Anonymous user
Sorting algorithms/Counting sort: Difference between revisions
Sorting algorithms/Counting sort (view source)
Revision as of 17:39, 4 September 2012
, 11 years ago→{{header|Haskell}}
(→{{header|REXX}}: arranged stemmed array assignments into columns for less space, indented DO loops more, added DO-END label comments. -- ~~~~) |
|||
Line 497:
myNewArray :: (Ix n) => (n,n) -> Int -> ST s (STArray s n Int)
myNewArray = newArray</lang>
Alternately:
<lang haskell>import Data.Array
countingSort :: (Enum n, Ix n) => [n] -> n -> n -> [n]
countingSort l lo hi = concatMap (uncurry $ flip replicate) count
where count = assocs . accumArray (+) 0 (lo, hi) . map (\i -> (i, 1)) $ l</lang>
=={{header|Io}}==
|