-- alist analogue of Data.Map.insertWith -> k -> a -> [(k, a)] -> [(k, a)] insertWith _ key val [] = [(key, val)] insertWith f key val (x@(k, v):xs) = if k == key then (key, f val v) : xs else x : insertWith f key val xs where updateCounts c = insertWith (+) c 1
Hello, World!