-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add Hamming exercise. #49
Conversation
Looks great, thanks! I think there is a one liner version too: hamming xs ys = guard (length xs == length ys) $> length (filter id (zipWith (/=) xs ys)) 😄 |
distance dna1 dna2 = case Tuple (uncons dna1) (uncons dna2) of | ||
Tuple (Just {head: h1, tail: t1}) (Just {head: h2, tail: t2}) -> (if h1 /= h2 then ((+) 1) else id) <$> distance t1 t2 | ||
Tuple Nothing Nothing -> Just 0 | ||
Tuple _ _ -> Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
End of file newline is missing here.
Could this have been written with multiple function clauses?
@@ -0,0 +1,46 @@ | |||
-- Test/exercise version: "1.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
I put a comment with the version number from the canonical data in. It should help keep track if new common tests are added, or the spec for the exercise is changed. Why is the new line at end of file important? A solution using |
I think the solution is good :) It's the version comment an established convention in exercism? |
Some streams look to be doing this: I maintain the ocaml stream and have added versions to a majority of tests. |
Seems like a good addition then. Thank you :) |
No description provided.