Implement groupByLink in terms of foldr

This commit is contained in:
Joseph C. Sible 2020-12-28 17:45:11 -05:00
parent cb4f4e7edc
commit 2c0766825e
1 changed files with 5 additions and 5 deletions

View File

@ -3858,13 +3858,13 @@ groupByLink :: (a -> a -> Bool) -> [a] -> [[a]]
groupByLink f list = groupByLink f list =
case list of case list of
[] -> [] [] -> []
(x:xs) -> g x [] xs (x:xs) -> foldr c n xs x []
where where
g current span (next:rest) = c next rest current span =
if f current next if f current next
then g next (current:span) rest then rest next (current:span)
else (reverse $ current:span) : g next [] rest else (reverse $ current:span) : rest next []
g current span [] = [reverse (current:span)] n current span = [reverse (current:span)]
prop_checkBlatantRecursion1 = verify checkBlatantRecursion ":(){ :|:& };:" prop_checkBlatantRecursion1 = verify checkBlatantRecursion ":(){ :|:& };:"