Skip to content

Commit 2c07668

Browse files
committed
Implement groupByLink in terms of foldr
1 parent cb4f4e7 commit 2c07668

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ShellCheck/Analytics.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3858,13 +3858,13 @@ groupByLink :: (a -> a -> Bool) -> [a] -> [[a]]
38583858
groupByLink f list =
38593859
case list of
38603860
[] -> []
3861-
(x:xs) -> g x [] xs
3861+
(x:xs) -> foldr c n xs x []
38623862
where
3863-
g current span (next:rest) =
3863+
c next rest current span =
38643864
if f current next
3865-
then g next (current:span) rest
3866-
else (reverse $ current:span) : g next [] rest
3867-
g current span [] = [reverse (current:span)]
3865+
then rest next (current:span)
3866+
else (reverse $ current:span) : rest next []
3867+
n current span = [reverse (current:span)]
38683868

38693869

38703870
prop_checkBlatantRecursion1 = verify checkBlatantRecursion ":(){ :|:& };:"

0 commit comments

Comments
 (0)