diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-05-11 22:07:09 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-05-11 22:07:09 +1000 |
commit | 4a5d01677ae457425336bf7de6ddffadf09bae83 (patch) | |
tree | 7cdfe6ce89bce948b6a5369d116207914cab9396 | |
parent | fd90e7cc9e2a3a792e3256b0604ea8c03176a889 (diff) |
Function to find all named nodes in a grasp program
-rw-r--r-- | src/Grasp/Types.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Grasp/Types.hs b/src/Grasp/Types.hs index 72f835a..af43d51 100644 --- a/src/Grasp/Types.hs +++ b/src/Grasp/Types.hs @@ -1,6 +1,7 @@ module Grasp.Types ( GraspProgram(..), + namedNodes, nodesWithName, normalise, iso @@ -28,6 +29,18 @@ instance (Ord a, Ord b) => Eq (Gr a b) where +namedNodes :: GraspProgram -> [LNode String] +namedNodes g = + let nodes = Graph.labNodes g + edges = Graph.labEdges g + + nameEdges = filter (\(_,_,z) -> z == "name") edges + nameNodes = map (\(x,_,_) -> x) nameEdges + + in filter (\(x,_) -> x `elem` nameNodes) nodes + + + nodesWithName :: GraspProgram -> String -> [LNode String] nodesWithName g s = let nodes = Graph.labNodes g |