commit @duckinator's minimum-unambiguous-path fn, per #16
This commit is contained in:
parent
72705caa5e
commit
8839c2f9c7
@ -43,3 +43,13 @@
|
|||||||
acc2 (conj acc pair)]
|
acc2 (conj acc pair)]
|
||||||
(if (empty? todo) (reverse acc2)
|
(if (empty? todo) (reverse acc2)
|
||||||
(recur acc2 row next (rest todo))))))
|
(recur acc2 row next (rest todo))))))
|
||||||
|
|
||||||
|
(defn minimum-unambiguous-path
|
||||||
|
([pronouns-table sections] (minimum-unambiguous-path pronouns-table sections 1))
|
||||||
|
([pronouns-table sections number-of-sections]
|
||||||
|
(let [sections-subset (take number-of-sections sections)
|
||||||
|
results (filter (fn [pronouns] (= (take number-of-sections pronouns) sections-subset)) pronouns-table)]
|
||||||
|
(case (count results)
|
||||||
|
0 nil
|
||||||
|
1 (clojure.string/join "/" sections-subset)
|
||||||
|
(recur pronouns-table sections (+ number-of-sections 1))))))
|
||||||
|
Loading…
Reference in New Issue
Block a user