From c7df9f4167f7b554a93a216245a013e16cca420d Mon Sep 17 00:00:00 2001 From: bringert Date: Sun, 17 Dec 2006 19:18:28 +0000 Subject: Added still unused implementation of Moore's LCLR algorithm for left recursion elimination. Fixed top category generation for SRG (included LR-elimination-added categories before). --- src/GF/Speech/Relation.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/GF/Speech/Relation.hs') diff --git a/src/GF/Speech/Relation.hs b/src/GF/Speech/Relation.hs index a62b4b1a7..fe91716c6 100644 --- a/src/GF/Speech/Relation.hs +++ b/src/GF/Speech/Relation.hs @@ -12,12 +12,13 @@ -- A simple module for relations. ----------------------------------------------------------------------------- -module GF.Speech.Relation (Rel, mkRel +module GF.Speech.Relation (Rel, mkRel, mkRel' , allRelated , isRelatedTo , transitiveClosure , reflexiveClosure, reflexiveClosure_ , symmetricClosure , symmetricSubrelation, reflexiveSubrelation + , reflexiveElements , equivalenceClasses , isTransitive, isReflexive, isSymmetric , isEquivalence @@ -38,6 +39,11 @@ type Rel a = Map a (Set a) mkRel :: Ord a => [(a,a)] -> Rel a mkRel ps = relates ps Map.empty +-- | Creates a relation from a list pairs of elements and the elements +-- related to them. +mkRel' :: Ord a => [(a,[a])] -> Rel a +mkRel' xs = Map.fromListWith Set.union [(x,Set.fromList ys) | (x,ys) <- xs] + relToList :: Rel a -> [(a,a)] relToList r = [ (x,y) | (x,ys) <- Map.toList r, y <- Set.toList ys ] -- cgit v1.2.3