This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vonfry
committed
May 23, 2017
1 parent
35c3a9c
commit f0cd8c3
Showing
7 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
-- | A tree data struct. | ||
|
||
module Data.Aima.Tree where | ||
|
||
|
||
-- | Tree class. | ||
-- | ||
-- @t@ is a tree data. It should have a param to save the node type. | ||
-- | ||
-- I suggest every instance of this class also instance "Eq" and "Ord" | ||
class Tree t where | ||
{-# MINIMAL parentTree, childrentTree, nodeT, insTree, delTree, orderTree #-} | ||
|
||
-- | Get the parent node of a tree. | ||
parentTree :: t a -> t a | ||
|
||
-- | Get the childrent trees of a tree. | ||
childrentTree :: t a -> [t a] | ||
|
||
-- | Get the current node of a tree. | ||
nodeT :: t a -> a | ||
|
||
-- | Insert a new node to an existing tree. | ||
insTree :: t a -> a -> t a | ||
|
||
-- | Delete a current node from the tree. | ||
delTree :: t a -> t a | ||
|
||
-- | Order the tree. | ||
orderTree :: t a -> t a | ||
|
||
|
||
-- | A Tree Node data. | ||
data TreeNode a = TreeNode { | ||
parent :: TreeNode a -- ^ parent node. | ||
, children :: [TreeNode a] -- ^ childrent. If you want to use BTree, set the count of children is 2. | ||
, node :: a -- ^ node. It contains the context and some other info. | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.