summaryrefslogtreecommitdiff
path: root/AAC_search_monad.ml
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2011-02-21 17:34:06 +0100
committerGravatar Stephane Glondu <steph@glondu.net>2011-02-21 17:34:06 +0100
commit9216cffaaa1ef137ef5bdb5b290a930cc6198850 (patch)
tree8a52503393953e68026a5b684b47616f49214f61 /AAC_search_monad.ml
parent8ab748064ddeec8400859e210bf9963826cba631 (diff)
Imported Upstream version 0.2.pl2upstream/0.2.pl2
Diffstat (limited to 'AAC_search_monad.ml')
-rw-r--r--AAC_search_monad.ml5
1 files changed, 5 insertions, 0 deletions
diff --git a/AAC_search_monad.ml b/AAC_search_monad.ml
index b7aabbd..09a6455 100644
--- a/AAC_search_monad.ml
+++ b/AAC_search_monad.ml
@@ -63,3 +63,8 @@ let to_list m = (fold (fun x acc -> x::acc) m [])
let sort f m =
N (List.map (fun x -> F x) (List.sort f (to_list m)))
+
+(* preserve the structure of the heap *)
+let filter f m =
+ fold (fun x acc -> (if f x then return x else fail ()) >>| acc) m (N [])
+