annotate categorical/monad.clj @ 9:23db8b1f0ee7
Softened tone in science minus science.
author |
Dylan Holmes <ocsenave@gmail.com> |
date |
Sat, 29 Oct 2011 21:18:54 -0500 |
parents |
b4de894a1e2e |
children |
|
rev |
line source |
rlm@2
|
1
|
rlm@2
|
2 (ns categorical.monad)
|
rlm@2
|
3 (use 'clojure.contrib.monads)
|
rlm@2
|
4
|
rlm@2
|
5 (in-ns 'categorical.monad)
|
rlm@2
|
6
|
rlm@2
|
7 ;; To implement nondeterministic programs, we'll use a lazy seq to represent a value which may be any one of the members of seq.
|
rlm@2
|
8
|
rlm@2
|
9 (defmonad amb
|
rlm@2
|
10 [
|
rlm@2
|
11 m-result (fn[& vals] (cons 'amb vals))
|
rlm@2
|
12 m-bind (fn[amb-seq f] (cons 'amb (map f (rest amb-seq))))
|
rlm@2
|
13 ]
|
rlm@2
|
14 )
|