Last active
August 31, 2016 22:34
-
-
Save hadielmougy/c7106028513ede43f9444bedda954d17 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
(defn longest [xs ys] (if (> (count xs) (count ys)) xs ys)) | |
(def lcs | |
(memoize | |
(fn [[x & xs] [y & ys]] | |
(cond | |
(or (= x nil) (= y nil) ) nil | |
(= x y) (cons x (lcs xs ys)) | |
:else (longest (lcs (cons x xs) ys) (lcs xs (cons y ys))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment