in Haskell
please solve maxNodeID and insertNode
The file includes a function named maxNode ID of type Graph a -> Maybe NodeID that returns the largest Node ID in a Graph. The file includes a function named insertNode of type a -> Graph a -> Graph a that inserts a new Node with the given value into a Graph. The new NodeID should be the previously largest NodeID plus one. If the graph has no nodes, then NodeID should be 0. The fi in
data Graph a = Graph { getNodes :: [Node a] Til||||1 l, getEdges :: [Edge] } deriving (Show, Eq) type Edge = (NodeID, NodeID) type NodeID = Int data Node a = Node { getNodeID :: NodeID, ILITI||| .getNodeVal :: a } deriving (Show, Eq,ord)
in Haskell please solve maxNodeID and insertNode
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am