Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
10
Task/Monads-List-monad/Clojure/monads-list-monad.clj
Normal file
10
Task/Monads-List-monad/Clojure/monads-list-monad.clj
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(defn bind [coll f] (apply vector (mapcat f coll)))
|
||||
(defn unit [val] (vector val))
|
||||
|
||||
(defn doubler [n] [(* 2 n)]) ; takes a number and returns a List number
|
||||
(def vecstr (comp vector str)) ; takes a number and returns a List string
|
||||
|
||||
(bind (bind (vector 3 4 5) doubler) vecstr) ; evaluates to ["6" "8" "10"]
|
||||
(-> [3 4 5]
|
||||
(bind doubler)
|
||||
(bind vecstr)) ; also evaluates to ["6" "8" "10"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue