From 181091ca690507f974647a56b532393c5b06e066 Mon Sep 17 00:00:00 2001 From: Solomon Bothwell Date: Tue, 4 Dec 2018 17:55:52 -0800 Subject: [PATCH] Update 05_collapse.org --- solutions/05_collapse.org | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/solutions/05_collapse.org b/solutions/05_collapse.org index e38cf86..58944ee 100644 --- a/solutions/05_collapse.org +++ b/solutions/05_collapse.org @@ -4,13 +4,19 @@ #+begin_src haskell +module Collapse where +import Data.List + xs :: [(Int, Int)] xs = [(1,3),(5,8),(2,5)] +xs' :: [(Int, Int)] +xs' = [(0,3), (1,260), (2,259)] + g :: [(Int, Int)] -> (Int, Int) -> [(Int, Int)] g a@((a1, a2):as) b@(b1, b2) = if (a2 - 1) >= b1 - then as ++ [(a1,b2)] + then if a2 > b2 then a else [(a1,b2)] ++ as else a ++ [b] h :: [(Int, Int)] -> [(Int, Int)]