This repository was archived by the owner on Feb 11, 2018. It is now read-only.
Conversation
|
Instead of returning (define (hamming-distance dna1 dna2)
(unless (= (string-length dna1) (string-length dna2))
(raise-argument-error 'hamming-distance "strings of equal length" 1 dna1 dna2))
(for/sum ([c1 (in-string dna1)]
[c2 (in-string dna2)])
(if (eqv? c1 c2) 0 1)))You can add tests for the bad cases using (check-exn #rx"strings of equal length"
(thunk (hamming-distance "AATG" "AAA"))
"disallow first strand longer") |
mbertheau
force-pushed
the
hamming
branch
3 times, most recently
from
May 14, 2015 23:31
d6f9d6e to
2755324
Compare
Owner
Author
|
Hmm, @lexi-lambda what do you think about this suggestion by zeodary? I think it expresses the idea of counting differences more directly. |
mbertheau
force-pushed
the
hamming
branch
2 times, most recently
from
May 22, 2015 21:27
951e9c0 to
5346664
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.