We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is a question about your zipWith article.
zipWith
Is flip essential in
flip
rotateUntil p xs = zipWith (flip const) xs (dropWhile (not . p) (cycle xs))
?
My guess is that this can be simplified to
rotateUntil p xs = zipWith const (dropWhile (not . p) (cycle xs)) xs
Am I correct?
The text was updated successfully, but these errors were encountered:
The answer is subtle, but the order of zip’s arguments matters:
zip
zipWith (flip const) [] (cycle []) :: [(Int,Int)] []
zipWith const (cycle []) [] :: [(Int,Int)] -- *** Exception: Prelude.cycle: empty list
The reason is that the first parameter is checked first, and when it’s empty, zip terminates without ever looking at the second.
Sorry, something went wrong.
No branches or pull requests
This is a question about your
zipWith
article.Is
flip
essential in?
My guess is that this can be simplified to
Am I correct?
The text was updated successfully, but these errors were encountered: