如何在Haskell中构建一个图形:
type Node = Int
type Arc = (Node, Node)
Run Code Online (Sandbox Code Playgroud)
和功能:
class Graph g where
build :: [Node] -> [Arc] -> g
Run Code Online (Sandbox Code Playgroud) 如何在Haskell中搜索二叉搜索树中的元素?我定义了我的树:
data Tree a =
Null |
L a |
N (Tree a) a (Tree a)
deriving Show
Run Code Online (Sandbox Code Playgroud)
我想创建一个在BST中搜索元素的函数:
findElem :: Tree a -> a -> Maybe a
findElem tree n = ...
Run Code Online (Sandbox Code Playgroud)
我该怎么做?