From 749186ec93377fdce2d893311ee284c30ad47069 Mon Sep 17 00:00:00 2001 From: Jacob Lagares Pozo Date: Fri, 9 Dec 2022 00:19:18 +0100 Subject: [PATCH] Simple `count` function. --- src/Advent/List.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Advent/List.hs b/src/Advent/List.hs index cb71e74..443a08c 100644 --- a/src/Advent/List.hs +++ b/src/Advent/List.hs @@ -23,3 +23,6 @@ splitOne delim list = chunks :: Int -> [a] -> [[a]] chunks n [] = [] chunks n xs = take n xs : chunks n (drop n xs) + +count :: (a -> Bool) -> [a] -> Int +count p = length . filter p -- 2.11.4.GIT