Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Amb/Clojure/amb.clj
Normal file
12
Task/Amb/Clojure/amb.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(ns amb
|
||||
(:use clojure.contrib.monads))
|
||||
|
||||
(defn amb [wss]
|
||||
(let [valid-word (fn [w1 w2]
|
||||
(if (and w1 (= (last w1) (first w2)))
|
||||
(str w1 " " w2)))]
|
||||
(filter #(reduce valid-word %)
|
||||
(with-monad sequence-m (m-seq wss)))))
|
||||
|
||||
amb> (amb '(("the" "that" "a") ("frog" "elephant" "thing") ("walked" "treaded" "grows") ("slowly" "quickly")))
|
||||
(("that" "thing" "grows" "slowly"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue