diff options
author | Jed Barber <jjbarber@y7mail.com> | 2012-10-07 20:45:46 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2012-10-07 20:45:46 +1100 |
commit | 50c50fc70fbe27e5fe37e572675b3ddac283f54b (patch) | |
tree | 5b0d3097e5011986f9486293b37ade33173e5036 /Library/Cost.hs | |
parent | 6b5d95562bb341b19d2a7407d646096b7ccbdea0 (diff) |
Dictionary methods cleaned up, Cost model library added
Diffstat (limited to 'Library/Cost.hs')
-rw-r--r-- | Library/Cost.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Library/Cost.hs b/Library/Cost.hs new file mode 100644 index 0000000..86cabdc --- /dev/null +++ b/Library/Cost.hs @@ -0,0 +1,29 @@ +module Library.Cost( + cost, + nodeCost, + listCost + ) where + + + +import Data.Maybe +import Data.Graph.Inductive.Graph( Node ) +import qualified Data.Graph.Inductive.Graph as Graph +import Library.ProofGraph + + + +cost :: String -> Int +cost x = 1 + + +nodeCost :: PGraph -> Node -> Int +nodeCost graph node = + let label = fromJust (Graph.lab graph node) + nextCostLayer = map (nodeCost graph) (Graph.suc graph node) + in (cost label) + (sum nextCostLayer) + + +listCost :: [String] -> Int +listCost = sum . (map cost) + |