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