Skip to content

Commit c7e0080

Browse files
committed
accumulate: fix inefficient example
The intent, I believe, is to show an example that would work and gives correct results but fails the non-strictness test. It was added in d238a33. In order for it to compile, the `xs` needs to be removed (an eta reduction has happened). In order for the results to be correct, final `acc` must be reversed.
1 parent 9c773f6 commit c7e0080

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

exercises/accumulate/src/Example.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ accumulate f xs = [f x | x <- xs]
1414
1515
-- Commonly submitted inefficient solution (we test for this now):
1616
17-
accumulate f xs = accumulate' []
17+
accumulate f = accumulate' []
1818
where
19-
accumulate' acc [] = acc
19+
accumulate' acc [] = reverse acc
2020
accumulate' acc (x:xs) = accumulate' (f x : acc) xs
2121
2222
-}

0 commit comments

Comments
 (0)