Created
September 20, 2010 19:53
-
-
Save mrBliss/588542 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-equal-subseq-for | |
"Returns the longest subsequence of indices for which the following | |
statement is true: | |
for all i, j in subsequence: (f i) = (f j) != nil | |
If there are subsequences of equal size, the last one is returned." | |
[f indices] | |
(let [subseqs (remove (comp nil? first) (partition-by f indices))] | |
(if (seq subseqs) | |
(apply (partial max-key count) subseqs) | |
subseqs))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment