Anonymous user
File size distribution: Difference between revisions
m
→{{header|Haskell}}
Line 426:
fileSizes = foldr f []
where
f (File _ n) acc = n
f _ acc = acc
Line 509:
| n >= 2^30 && n <= 2^40 = display (2^30) "GB"
| n >= 2^40 && n <= 2^50 = display (2^40) "TB"
| otherwise =
where
display :: Double -> String -> String
Line 519:
collectItems :: FilePath -> IO [Item]
collectItems folderPath = catch tryCollect $ \e -> do
hPrintf stderr "Skipping: %s\n" $ show (e :: IOException)
pure []
where
tryCollect = do
Line 559 ⟶ 558:
loop :: Chan FilePath -> Chan [Item] -> [Item] -> IO [Item]
loop folderChan resultItemsChan xs = do
if null regularFolders then pure []
else do
Line 583 ⟶ 581:
putStrLn $ replicate 46 '-'
let results = expandedGroups groupSize (sizes items) (groupThreshold fileCount) items
mapM_ (displayFrequency fileCount) $ Map.assocs results
where
|