Skip to content
Snippets Groups Projects
Commit 999ced14 authored by Thorsten Wißmann's avatar Thorsten Wißmann
Browse files

Add first disjoint-list notes

parent d9fa5123
Branches
No related tags found
No related merge requests found
......@@ -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 *)
......
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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment