Skip to content

Commit 533f561

Browse files
committed
Change 1brc example to use built in aggregation.
1 parent 4218a15 commit 533f561

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

app/Main.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,13 @@ main = do
3838
covid
3939
putStrLn $ replicate 100 '-'
4040

41-
42-
mean :: (Fractional a, VG.Vector v a) => v a -> a
43-
mean xs = VG.sum xs / fromIntegral (VG.length xs)
44-
4541
oneBillingRowChallenge :: IO ()
4642
oneBillingRowChallenge = do
4743
parsed <- D.readSeparated ';' D.defaultOptions "./data/measurements.txt"
4844
print $
4945
parsed
5046
|> D.groupBy ["City"]
51-
|> D.reduceBy (\v -> (VG.minimum v, mean @Double v, VG.maximum v)) "Measurement"
47+
|> D.aggregate (zip (repeat "Measurement") [D.Minimum, D.Mean, D.Maximum])
5248
|> D.sortBy D.Ascending ["City"]
5349

5450
housing :: IO ()

0 commit comments

Comments
 (0)