diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-04-08 15:06:40 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-04-08 15:06:40 +1000 |
commit | 03d38eb3190eb5e51fb18847fe0792013285bde5 (patch) | |
tree | 1060d26d3042b5c0c5b1c027fac45fe87f3d685a /src/Library/Cost.hs | |
parent | f2c4e4614613ede497f19ef79dc7dc157eaca834 (diff) |
Reorganising source code
Diffstat (limited to 'src/Library/Cost.hs')
-rw-r--r-- | src/Library/Cost.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Library/Cost.hs b/src/Library/Cost.hs new file mode 100644 index 0000000..86cabdc --- /dev/null +++ b/src/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) + |