Anonymous user
File size distribution: Difference between revisions
m
→{{header|Haskell}}
Line 453:
) (0, 0)
groupsFromGroup :: Int -> [Integer] -> FrequencyGroup -> [FrequencyGroup]
groupsFromGroup gsize fileSizes ((min, max), count) = frequencyGroups
where
collectBetween min max = filter (\n -> n >= min && n <= max)
range = collectBetween min max fileSizes
expandGroups :: Int -> [Integer] -> Integer -> [FrequencyGroup] -> [FrequencyGroup]
expandGroups gsize fileSizes groupThreshold groups
| all ((<= groupThreshold) . snd) groups = groups
| otherwise = expandGroups gsize fileSizes groupThreshold $ expand groups
where
expand = ((\g@((min, max), count) ->
if count > groupThreshold then
groupsFromGroup gsize fileSizes g
else
[g]
Line 549:
putStrLn "\nDistribution:"
let results = filteredGroups groupSize items
deepResults = expandedGroups groupSize (sizes items) (groupThreshold fileCount) results
mapM_ (displayFrequency fileCount) deepResults
where
Line 555:
filteredGroups n = filter ((>0) . snd) . frequencyGroups n . sizes
groupThreshold = round . (*0.25) . realToFrac
expandedGroups gsize sizes n = filter ((>0) . snd) . expandGroups gsize sizes n</lang>
{{out}}
<pre style="height: 50rem;">$ filedist
Using 4 worker threads
Total files:
Total folders: 65528
Total size: 6GB
Distribution:
0B <-> 75B = 39305 9.103%: ████████████████████████████████████
76B <-> 151B = 36175 8.378%: ██████████████████████████████████
152B <-> 227B = 27747 6.426%: ██████████████████████████
228B <-> 303B = 19148 4.434%: ██████████████████
301B <-> 601B = 50919 11.792%: ███████████████████████████████████████████████
602B <-> 902B = 41885 9.700%: ███████████████████████████████████████
903B <-> 1KB = 43986 10.187%: █████████████████████████████████████████
1KB <-> 2KB = 61277 14.191%: █████████████████████████████████████████████████████████
2KB <-> 4KB = 29473 6.826%: ███████████████████████████
4KB <-> 5KB = 17620 4.081%: ████████████████
5KB <-> 9KB = 28951 6.705%: ███████████████████████████
9KB <-> 14KB = 10941 2.534%: ██████████
14KB <-> 19KB = 5139 1.190%: █████
19KB <-> 37KB = 8589 1.989%: ████████
▲322KB <-> 403KB = 287 0.066%:
98MB <-> 196MB = 8 0.002%:
294MB <-> 392MB = 1 0.000%: </pre>
=={{header|Julia}}==
|