Mercurial > dylan
comparison categorical/monad.clj @ 2:b4de894a1e2e
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 28 Oct 2011 00:03:05 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:8d8278e09888 | 2:b4de894a1e2e |
---|---|
1 | |
2 (ns categorical.monad) | |
3 (use 'clojure.contrib.monads) | |
4 | |
5 (in-ns 'categorical.monad) | |
6 | |
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. | |
8 | |
9 (defmonad amb | |
10 [ | |
11 m-result (fn[& vals] (cons 'amb vals)) | |
12 m-bind (fn[amb-seq f] (cons 'amb (map f (rest amb-seq)))) | |
13 ] | |
14 ) |