-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync hamming tests and update stub (#243)
- Loading branch information
Showing
3 changed files
with
32 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
(defmodule hamming | ||
(export (distance 2))) | ||
|
||
(defun distance (strand-x strand-y) | ||
(lists:sum | ||
(lists:zipwith | ||
(lambda (x y) (if (=:= x y) 0 1)) | ||
strand-x strand-y))) | ||
(defun distance (strand1 strand2) | ||
(if (not (== (length strand1) (length strand2))) | ||
(error "strands must have the same length") | ||
(lists:sum | ||
(lists:zipwith | ||
(lambda (a b) (if (=:= a b) 0 1)) | ||
strand1 | ||
strand2)))) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(defmodule hamming | ||
(export (distance 2))) | ||
|
||
; Please implement the distance function. |
This file contains 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