Sorting algorithms/Counting sort: Difference between revisions

(→‎{{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}}==
Anonymous user