From 98d0af8d73ee56fdb9c64626e173eec0ebbce5e7 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Thu, 8 Jun 2006 21:19:40 +0000 Subject: [PATCH] add the chartAssocs function. It returns both the key and the item. --- src/GF/Data/GeneralDeduction.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/GF/Data/GeneralDeduction.hs b/src/GF/Data/GeneralDeduction.hs index ea139bb4d..137212e5c 100644 --- a/src/GF/Data/GeneralDeduction.hs +++ b/src/GF/Data/GeneralDeduction.hs @@ -21,7 +21,7 @@ module GF.Data.GeneralDeduction emptyChart, chartMember, chartInsert, chartInsertM, - chartList, chartKeys, + chartList, chartKeys, chartAssocs, addToChart, addToChartM ) where @@ -36,6 +36,7 @@ import Control.Monad (foldM) chartLookup :: (Ord item, Ord key) => ParseChart item key -> key -> [item] chartList :: (Ord item, Ord key) => ParseChart item key -> [item] chartKeys :: (Ord item, Ord key) => ParseChart item key -> [key] +chartAssocs :: (Ord item, Ord key) => ParseChart item key -> [(key,item)] buildChart :: (Ord item, Ord key) => (item -> key) -- ^ key lookup function -> [ParseChart item key -> item -> [item]] -- ^ list of inference rules as functions @@ -97,6 +98,7 @@ chartMember (KC tree) item key = rbmElem key item tree chartLookup (KC tree) key = rbmLookup key tree chartList (KC tree) = concatMap snd (rbmList tree) chartKeys (KC tree) = map fst (rbmList tree) +chartAssocs (KC tree) = [(key,item) | (key,items) <- rbmList tree, item <- items] chartInsert (KC tree) item key = fmap KC (rbmInsert key item tree) chartInsertM (KC tree) item keys = fmap KC (foldM insertItem tree keys)