File size distribution: Difference between revisions

Content added Content deleted
(added Haskell)
Line 391:
</pre>
=={{header|Haskell}}==
Uses grouped frequency distribution. Program arguments include directory and frequency distribution group size. Distribution groups of 0 are removed.
<lang haskell>{-# LANGUAGE TupleSections #-}
 
Line 434:
displaySize n
| n <= 2^10 = show n <> "B"
| n >= 2^10 && n <= 2^20 = showf (n"KB" `div`$ 2^10) <> "KB"
| n >= 2^20 && n <= 2^30 = showf (n"MB" `div`$ 2^20) <> "MB"
| n >= 2^30 && n <= 2^40 = showf (n"GB" `div`$ 2^30) <> "GB"
| n >= 2^40 && n <= 2^50 = showf (n"TB" `div`$ 2^40) <> "TB"
| otherwise = "Too large!"
where
f suffix = (<> suffix) . show . round . (realToFrac n /)
 
collectItems :: FilePath -> IO [Item]
Line 494 ⟶ 496:
156MB <-> 195MB = 1
352MB <-> 391MB = 1</pre>
 
=={{header|Julia}}==
{{works with|Julia|0.6}}