Skip to content

Commit 6c89ec7

Browse files
📚 docs(README): Move "Add values" before "Slice".
1 parent f4c7f90 commit 6c89ec7

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

README.md

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ Parent is [@aureooms/js-persistent](https://github.com/aureooms/js-persistent).
4242
* [:question: Predicates](#question-predicates)
4343
* [`Tree#measure() -> m`](#treemeasure---m)
4444
* [`Tree#empty() -> Boolean`](#treeempty---boolean)
45-
* [:pizza: Slice](#pizza-slice)
46-
* [`Tree#head() -> x`](#treehead---x)
47-
* [`Tree#last() -> x`](#treelast---x)
48-
* [`Tree#init() -> Tree`](#treeinit---tree)
49-
* [`Tree#tail() -> Tree`](#treetail---tree)
5045
* [:salt: Add values](#salt-add-values)
5146
* [`Tree#push(x) -> Tree`](#treepushx---tree)
5247
* [`Tree#cons(x) -> Tree`](#treeconsx---tree)
5348
* [`Tree#append(Iterable) -> Tree`](#treeappenditerable---tree)
5449
* [`Tree#prepend(Iterable) -> Tree`](#treeprependiterable---tree)
50+
* [:pizza: Slice](#pizza-slice)
51+
* [`Tree#head() -> x`](#treehead---x)
52+
* [`Tree#last() -> x`](#treelast---x)
53+
* [`Tree#init() -> Tree`](#treeinit---tree)
54+
* [`Tree#tail() -> Tree`](#treetail---tree)
5555
* [:last_quarter_moon: Merge](#last_quarter_moon-merge)
5656
* [`Tree#concat(Tree) -> Tree`](#treeconcattree---tree)
5757
* [:broken_heart: Split](#broken_heart-split)
@@ -75,12 +75,14 @@ All methods are pure functions that do not modify their object.
7575
> The [parent project](https://github.com/aureooms/js-persistent) shows how
7676
> specialized persistent data structures can be build on top of those methods.
7777
78+
7879
### :cactus: Definition of a `Tree`
7980

8081
data Tree x = Empty
8182
| Single x
8283
| Deep ( Digit x ) ( Tree ( Node x ) ) ( Digit x )
8384

85+
8486
### :straight_ruler: Definition of a `Measure`
8587

8688
Measure = (
@@ -129,6 +131,7 @@ const { from , empty } = require( '@aureooms/js-fingertree' ) ;
129131
import { from , empty } from '@aureooms/js-fingertree' ;
130132
```
131133

134+
132135
### :baby: How to create a `Tree`
133136

134137
#### `empty(Measure) -> Tree`
@@ -147,6 +150,7 @@ Create a tree from a measure object and an iterable.
147150
let tree = from( counter , 'abc' ) ;
148151
```
149152

153+
150154
### :question: Predicates
151155

152156
#### `Tree#measure() -> m`
@@ -165,74 +169,77 @@ Returns `true` if the tree is empty, `false` otherwise.
165169
return tree.empty() ? 'empty' : 'not empty' ;
166170
```
167171

168-
### :pizza: Slice
169172

170-
#### `Tree#head() -> x`
173+
### :salt: Add values
171174

172-
Returns the left-most value in the tree.
175+
#### `Tree#push(x) -> Tree`
176+
177+
Returns a new tree with an additional value as the new right-most value.
173178

174179
```js
175-
let head = tree.head() ; // 'a'
180+
tree = tree.cons('k');
176181
```
177182

178-
#### `Tree#last() -> x`
183+
#### `Tree#cons(x) -> Tree`
179184

180-
Returns the right-most value in the tree.
185+
Returns a new tree with an additional value as the new left-most value.
181186

182187
```js
183-
let last = tree.last() ; // 'b'
188+
tree = tree.cons('g');
184189
```
185190

186-
#### `Tree#init() -> Tree`
191+
#### `Tree#append(Iterable) -> Tree`
187192

188-
Returns a new tree without the right-most value.
193+
Equivalent to applying `push` to each value of the iterable in order.
189194

190195
```js
191-
while ( ! tree.empty() ) tree = tree.init() ;
196+
tree.append( 'www' ) ;
192197
```
193198

194-
#### `Tree#tail() -> Tree`
199+
#### `Tree#prepend(Iterable) -> Tree`
195200

196-
Returns a new tree without the left-most value.
201+
Equivalent to applying `cons` to each value of the iterable in reverse order.
197202

198203
```js
199-
while ( ! tree.empty() ) tree = tree.tail() ;
204+
tree.prepend( 'xyz' ) ;
200205
```
201206

202-
### :salt: Add values
203207

204-
#### `Tree#push(x) -> Tree`
208+
### :pizza: Slice
205209

206-
Returns a new tree with an additional value as the new right-most value.
210+
#### `Tree#head() -> x`
211+
212+
Returns the left-most value in the tree.
207213

208214
```js
209-
tree = tree.cons('k');
215+
let head = tree.head() ; // 'a'
210216
```
211217

212-
#### `Tree#cons(x) -> Tree`
218+
#### `Tree#last() -> x`
213219

214-
Returns a new tree with an additional value as the new left-most value.
220+
Returns the right-most value in the tree.
215221

216222
```js
217-
tree = tree.cons('g');
223+
let last = tree.last() ; // 'b'
218224
```
219225

220-
#### `Tree#append(Iterable) -> Tree`
226+
#### `Tree#init() -> Tree`
221227

222-
Equivalent to applying `push` to each value of the iterable in order.
228+
Returns a new tree without the right-most value.
223229

224230
```js
225-
tree.append( 'www' ) ;
231+
while ( ! tree.empty() ) tree = tree.init() ;
226232
```
227233

228-
#### `Tree#prepend(Iterable) -> Tree`
234+
#### `Tree#tail() -> Tree`
229235

230-
Equivalent to applying `cons` to each value of the iterable in reverse order.
236+
Returns a new tree without the left-most value.
231237

232238
```js
233-
tree.prepend( 'xyz' ) ;
239+
while ( ! tree.empty() ) tree = tree.tail() ;
234240
```
235241

242+
236243
### :last_quarter_moon: Merge
237244

238245
#### `Tree#concat(Tree) -> Tree`

0 commit comments

Comments
 (0)