-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
firstRepeat test "removing repeats matches nub" doesn't really work. #400
Comments
My implementation for firstRepeat :: Ord a => List a -> Optional a
firstRepeat as = eval (findM p as) S.empty
where
p x = State (\s -> (S.member x s, S.insert x s)) The function appears to return correctly for the input in question, but I may be misunderstanding? 🤔
|
Yes, mine is very similar, but the test still fails. The test is the thing that is wrong. |
PR please :) |
@pedrofurla it seems that you believe that |
The code in question https://github.com/system-f/fp-course/blob/master/src/Test/StateTest.hs#L127:
The spans and the list reconstruction don't account for lists with multiple repetitions. The test fail for this input
listh [4,10,1,9,9,8,2,-9,10,8]
, wherel3 == [4,10,1,9,9,8,2,-9] && nub l3 == [4,10,1,9,8,2,-9]
.An alternative is removing all repetitions:
Happy to make a PR.
The text was updated successfully, but these errors were encountered: