Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonrichardson/fantasy-trees
Tree data structure
https://github.com/simonrichardson/fantasy-trees
Last synced: 22 days ago
JSON representation
Tree data structure
- Host: GitHub
- URL: https://github.com/simonrichardson/fantasy-trees
- Owner: SimonRichardson
- Created: 2013-11-26T23:13:56.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-28T21:18:25.000Z (almost 11 years ago)
- Last Synced: 2024-05-01T23:21:30.694Z (6 months ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fantasy Tree
This library implements purely functional, monadic homogenous tree
data structure.## Types
The current implementation of Fantasy Tree has two type different
structures.* Binary Tree
* Finger Tree### Binary Tree
```javascript
var ord = function(x) {
return function(y) {
return x < y ? -1 : x > y ? 1 : 0;
};
},
tree = BinaryTree.of(1).insert(2, ord).insert(3, ord).map(function(a) {
return a + 1;
});
```The Binary Tree is a non-balanced possible empty tree structure. It's
currently only a Functor and Applicative Functor, although with a
bit of effort could become a Monoid as concatenation of the tree is
quite complex.### Finger Tree
```javascript
var tree = FingerTree.Fork(
FingerTree.of(1),
FingerTree.Fork(
FingerTree.of(2),
FingerTree.of(3)
)
).map(
function(a) {
return a + 1;
}
);
```The Finger Tree is a non-balanced non-empty tree structure. It's
currently only a Functor.## Fantasy Land Compatible
[
![](https://raw.github.com/fantasyland/fantasy-land/master/logo.png)
](https://github.com/fantasyland/fantasy-land)