### Profile

Statistics
| Branch: | Revision:

## cool / playground.hs @ master

 1 ```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 = killsubsets . maxdisj' [] ``` ```-- test it with: ``` ```-- flip (>>=) (return . length) \$ mapM putStrLn \$ map show \$ maxdisj [[1,2],[2,3],[3,4]] ``` ```-- ``` ```killsubsets :: Eq a => [[[a]]] -> [[[a]]] ``` ```killsubsets ccc = filter (\m -> not (any (\cc -> m `subset` cc) ccc)) ccc ``` ```subset :: Eq a => [a] -> [a] -> Bool ``` ```subset a b = (all (`elem` b) a) && ((length a) < (length b)) ``` ```-- generate all disjoint subsets... ``` ```maxdisj' :: Eq a => [[a]] -> [[a]] -> [[[a]]] ``` ```maxdisj' pool (x:xs) = oth2 -- extendable ++ maximal ``` ``` where oth = maxdisj' (x:pool) xs ``` ``` oth2 = oth ++ (map (x:) \$ filter (all (disjoint x)) oth) ``` ```maxdisj' _ [] = [[]] ``` ```-- old helper functions: ``` ``` --(maximal,nonmaximal) = partition isMaximal oth2 ``` ``` --isMaximal cc = let sups = filter (cc `subset`) oth2 ``` ``` -- in all (\p -> ((not . compatible p cc) ``` ``` -- `or` ``` ``` -- (flip all sups (not . compatible p)))) pool ``` ``` --subset a b = all (`elem` a) b `and` (length a) < (length b) ``` ``` --compatible x cc = all (disjoint x) cc ``` ```disjoint :: Eq a => [a] -> [a] -> Bool ``` ```disjoint x = all (not . flip elem x) ```