This commit is contained in:
Sijmen 2018-12-01 18:09:41 +01:00
parent a68afd169e
commit 2be3c1f086
1 changed files with 2 additions and 3 deletions

View File

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