Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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