Created
December 11, 2009 14:31
-
-
Save kirel/254237 to your computer and use it in GitHub Desktop.
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
(ns org.kirelabs.classifijure.elastic | |
(:use | |
[clojure.test] | |
[incanter.core]) | |
) | |
(defn match-elastic | |
[sequence other measure] | |
(let [measure (memoize measure)] | |
(letfn [(match | |
[sequence other] | |
(cond | |
(empty? (rest sequence)) | |
(reduce + (map #(measure (first sequence) %) other)) | |
(empty? (rest other)) | |
(reduce + (map #(measure % (first other)) sequence)) | |
:else (+ (measure (first sequence) (first other)) | |
(min (match sequence (rest other)) | |
(match (rest sequence) other) | |
(match (rest sequence) (rest other)))) | |
) | |
)] | |
(let [match (memoize match)] | |
(match sequence other) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment