This commit is contained in:
Sijmen 2018-12-01 18:09:41 +01:00
parent a68afd169e
commit 2be3c1f086

View file

@ -5,9 +5,8 @@ import qualified Data.IntSet as S
handle :: Int -> S.IntSet -> [Int] -> Int handle :: Int -> S.IntSet -> [Int] -> Int
handle freq history (nextDelta:xs) handle freq history (nextDelta:xs)
| (S.size s) == (S.size history) = freq -- When the frequency is in the history set, return it | S.member freq history = freq -- When the frequency is in the history set, return it
| otherwise = handle (freq + nextDelta) (S.insert freq history) xs -- Recurse otherwise | otherwise = handle (freq + nextDelta) (S.insert freq history) xs -- Recurse otherwise
where s = S.insert freq history
handle _ _ _ = error "xs should not be empty :(" handle _ _ _ = error "xs should not be empty :("
main :: IO () main :: IO ()