From 999ced14a7e7d882a19e76dceaec7ce87faa2f7c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thorsten=20Wi=C3=9Fmann?= <uni@thorsten-wissmann.de>
Date: Thu, 9 Jan 2014 17:37:28 +0100
Subject: [PATCH] Add first disjoint-list notes

---
 CoAlgLogics.ml |  1 -
 playground.hs  | 29 +++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 playground.hs

diff --git a/CoAlgLogics.ml b/CoAlgLogics.ml
index 1cd8324..14d8d64 100644
--- a/CoAlgLogics.ml
+++ b/CoAlgLogics.ml
@@ -155,7 +155,6 @@ let mkRule_MultiModalKD sort bs sl =
     /  \i=1 a_i        /\    b   /  \j=1 c_j
 *)
 
-
 let mkRule_CL sort bs sl =
   assert (List.length sl = 1); (* TODO: Why? *)
   let s1 = List.hd sl in (* [s1] = List.hd sl *)
diff --git a/playground.hs b/playground.hs
new file mode 100644
index 0000000..0f394ff
--- /dev/null
+++ b/playground.hs
@@ -0,0 +1,29 @@
+
+import Control.Monad
+import Data.List
+import System.IO
+
+-- some example functions which will be adapted to ocaml
+
+--                 mutliset  -> disjoint subset
+--                 of sets      /   / .... all those maximal ones
+--                 |   |       |   | /
+maxdisj :: Eq a => [[a]]   -> [[[a]]]
+maxdisj = maxdisj' []
+
+-- test it with:
+-- flip (>>=) (return . length) $  mapM putStrLn $ map show $ maxdisj [[1,2],[2,3],[3,4]]
+
+--   only keep subsets if they intersect with pool -- does not work yet... TODO
+maxdisj' :: Eq a => [[a]] -> [[a]]   -> [[[a]]]
+maxdisj' pool (x:xs) = (map (x:) oth') ++ maximal
+  where oth  = maxdisj' (x:pool) xs ++ [[]]
+        oth' = filter (compatible x) oth
+        maximal = filter (\s -> all (not . flip compatible s) pool) oth
+        expandable = filter (\s -> any (flip compatible s) pool) oth
+        compatible set setset = all (disjoint set) setset
+maxdisj' _ [] = [[]]
+
+disjoint :: Eq a => [a] -> [a] -> Bool
+disjoint x = all (not . flip elem x)
+
-- 
GitLab