Skip to content

Commit 27bcaac

Browse files
committed
docs update
1 parent 3228e27 commit 27bcaac

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

README.md

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
[![Build Status](https://travis-ci.org/Jutho/TupleTools.jl.svg?branch=master)](https://travis-ci.org/Jutho/TupleTools.jl) [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md) [![Coverage Status](https://coveralls.io/repos/Jutho/TupleTools.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/Jutho/TupleTools.jl?branch=master) [![codecov.io](http://codecov.io/github/Jutho/TupleTools.jl/coverage.svg?branch=master)](http://codecov.io/github/Jutho/TupleTools.jl?branch=master)
88

99

10-
A bunch of tools for using tuples (mostly homogeneous tuples `NTuple{N}`) as a collection and performing a number of operations with an inferrable result, typically also an `NTuple{M}` with inferable length `M`. Type inference breaks down if some of the final or intermediate tuples exceed `MAX_TUPLETYPE_LEN`, meaning inference typically works up to output tuples of length `13` or `14`. Chosen implementations are typically faster than the corresponding functions in base for those small tuple lengths, but can be slower for larger tuples. Inference also breaks down for most functions in case of inhomogeneous tuples. Some algorithms also provide reasonable defaults assuming that they are used for tuples of `Int`s, i.e. `TupleTools.sum(()) = 0` or `TupleTools.prod(()) = 1` (whereas the corresponding Base functions would error). This originates from the assumption that these methods are used to operate on tuples of e.g. sizes, indices or strides of multidimensional arrays.
10+
A bunch of tools for using tuples (mostly homogeneous tuples `NTuple{N}`) as a collection and performing a number of operations with an inferrable result, typically also an `NTuple{M}` with inferable length `M`. ~~Type inference breaks down if some of the final or intermediate tuples exceed `MAX_TUPLETYPE_LEN`, meaning inference typically works up to output tuples of length `13` or `14`.~~ Chosen implementations are typically faster than the corresponding functions in base for those small tuple lengths, but can be slower for larger tuples. Inference breaks down for most functions in case of inhomogeneous tuples.
1111

1212

13-
Note that none of the following functions are exported, since their name often collides with the equivalent functions (with different implementations) in `Base`.
13+
Note that none of the following functions are exported, since their name often collides with the equivalent functions (with different implementations) in `Base`. Some functions here provided just have an equivalent in `Base` that doesn't work for tuples at all, like `sort`. Some functions also provide reasonable defaults assuming that they are used for tuples of `Int`s, i.e. `TupleTools.sum(()) = 0` or `TupleTools.prod(()) = 1` (whereas the corresponding `Base` functions would error). This originates from the assumption that these methods are used to operate on tuples of e.g. sizes, indices or strides of multidimensional arrays.
1414

1515

1616
<a id='Types-1'></a>
@@ -39,7 +39,7 @@ StaticLength(N₁) - StaticLength(N₂) == StaticLength(max(0, N₁-N₂))
3939
```
4040

4141

42-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L8-L22' class='documenter-source'>source</a><br>
42+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L10-L24' class='documenter-source'>source</a><br>
4343

4444

4545
<a id='Functions-1'></a>
@@ -58,7 +58,7 @@ tail2(t::Tuple) -> ::Tuple
5858
Returns a tuple with the first two elements stripped, equivalent to `tail(tail(t))`
5959

6060

61-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L37-L41' class='documenter-source'>source</a><br>
61+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L34-L38' class='documenter-source'>source</a><br>
6262

6363
<a id='TupleTools.unsafe_tail' href='#TupleTools.unsafe_tail'>#</a>
6464
**`TupleTools.unsafe_tail`** &mdash; *Function*.
@@ -72,7 +72,7 @@ unsafe_tail(t::Tuple) -> ::Tuple
7272
Returns a tuple with the first element stripped, similar to `tail(t)`, but does not error on an empty tuple (instead returning an empty tuple again). An empty tuple is thus the fixed point of this function.
7373

7474

75-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L44-L50' class='documenter-source'>source</a><br>
75+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L41-L47' class='documenter-source'>source</a><br>
7676

7777
<a id='TupleTools.unsafe_front' href='#TupleTools.unsafe_front'>#</a>
7878
**`TupleTools.unsafe_front`** &mdash; *Function*.
@@ -86,7 +86,7 @@ unsafe_front(t::Tuple) -> ::Tuple
8686
Returns a tuple with the last element stripped, similar to `front(t)`, but does not error on an empty tuple (instead returning an empty tuple again). An empty tuple is thus the fixed point of this function.
8787

8888

89-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L54-L60' class='documenter-source'>source</a><br>
89+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L51-L57' class='documenter-source'>source</a><br>
9090

9191
<a id='TupleTools.getindices' href='#TupleTools.getindices'>#</a>
9292
**`TupleTools.getindices`** &mdash; *Function*.
@@ -100,7 +100,7 @@ getindices(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
100100
Get the indices `t[i] for i in I`, again as tuple.
101101

102102

103-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L288-L292' class='documenter-source'>source</a><br>
103+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L272-L276' class='documenter-source'>source</a><br>
104104

105105
<a id='TupleTools.deleteat' href='#TupleTools.deleteat'>#</a>
106106
**`TupleTools.deleteat`** &mdash; *Function*.
@@ -115,7 +115,7 @@ deleteat(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
115115
Delete the element at location `i` in `t`; if a list `I` of indices is specified (again as a tuple), the elements of these different positions are deleted.
116116

117117

118-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L76-L82' class='documenter-source'>source</a><br>
118+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L73-L79' class='documenter-source'>source</a><br>
119119

120120
<a id='TupleTools.insertat' href='#TupleTools.insertat'>#</a>
121121
**`TupleTools.insertat`** &mdash; *Function*.
@@ -129,7 +129,7 @@ insertat(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
129129
Insert the elements of tuple `t2` at location `i` in `t`, i.e. the output tuple will look as (t[1:i-1]..., t2..., t[i+1:end]). Note that element `t[i]` is deleted. Use `setindex` for setting a single value at position `i`, or `insertafter(t, i, t2)` to insert the contents of `t2` in between element `i` and `i+1` in `t`.
130130

131131

132-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L97-L105' class='documenter-source'>source</a><br>
132+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L94-L101' class='documenter-source'>source</a><br>
133133

134134
<a id='TupleTools.insertafter' href='#TupleTools.insertafter'>#</a>
135135
**`TupleTools.insertafter`** &mdash; *Function*.
@@ -143,7 +143,7 @@ insertafter(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
143143
Insert the elements of tuple `t2` after location `i` in `t`, i.e. the output tuple will look as (t[1:i]..., t2..., t[i+1:end]). Use index `i=0` or just `(t2..., t...)` to insert `t2` in front of `t`; also see `insertat` to overwrite the element at position `i`.
144144

145145

146-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L110-L117' class='documenter-source'>source</a><br>
146+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L108-L114' class='documenter-source'>source</a><br>
147147

148148
<a id='TupleTools.vcat' href='#TupleTools.vcat'>#</a>
149149
**`TupleTools.vcat`** &mdash; *Function*.
@@ -157,7 +157,7 @@ vcat(args...) -> ::Tuple
157157
Like `vcat` for tuples, concatenates a combination of tuple arguments and non-tuple arguments into a single tuple. Only works one level deep, i.e. tuples in tuples are not expanded.
158158

159159

160-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L64-L70' class='documenter-source'>source</a><br>
160+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L61-L67' class='documenter-source'>source</a><br>
161161

162162
<a id='TupleTools.sum' href='#TupleTools.sum'>#</a>
163163
**`TupleTools.sum`** &mdash; *Function*.
@@ -171,7 +171,7 @@ sum(t::Tuple)
171171
Returns the sum of the element of a tuple, or `0` for an empty tuple.
172172

173173

174-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L122-L126' class='documenter-source'>source</a><br>
174+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L122-L126' class='documenter-source'>source</a><br>
175175

176176
<a id='Base.cumsum' href='#Base.cumsum'>#</a>
177177
**`Base.cumsum`** &mdash; *Function*.
@@ -185,7 +185,21 @@ cumsum(t::Tuple)
185185
Returns the cumulative sum of the elements of a tuple, or `()` for an empty tuple.
186186

187187

188-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L131-L135' class='documenter-source'>source</a><br>
188+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L131-L135' class='documenter-source'>source</a><br>
189+
190+
<a id='TupleTools.diff' href='#TupleTools.diff'>#</a>
191+
**`TupleTools.diff`** &mdash; *Function*.
192+
193+
194+
195+
```
196+
diff(v::Tuple) -> Tuple
197+
```
198+
199+
Finite difference operator of tuple `v`.
200+
201+
202+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L318-L322' class='documenter-source'>source</a><br>
189203

190204
<a id='TupleTools.prod' href='#TupleTools.prod'>#</a>
191205
**`TupleTools.prod`** &mdash; *Function*.
@@ -199,7 +213,7 @@ prod(t::Tuple)
199213
Returns the product of the elements of a tuple, or `1` for an empty tuple.
200214

201215

202-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L143-L147' class='documenter-source'>source</a><br>
216+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L143-L147' class='documenter-source'>source</a><br>
203217

204218
<a id='Base.cumprod' href='#Base.cumprod'>#</a>
205219
**`Base.cumprod`** &mdash; *Function*.
@@ -213,7 +227,7 @@ cumprod(t::Tuple)
213227
Returns the cumulative product of the elements of a tuple, or `()` for an empty tuple.
214228

215229

216-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L152-L156' class='documenter-source'>source</a><br>
230+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L152-L156' class='documenter-source'>source</a><br>
217231

218232
<a id='TupleTools.minimum' href='#TupleTools.minimum'>#</a>
219233
**`TupleTools.minimum`** &mdash; *Function*.
@@ -227,7 +241,7 @@ minimum(t::Tuple)
227241
Returns the smallest element of a tuple
228242

229243

230-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L164-L168' class='documenter-source'>source</a><br>
244+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L164-L168' class='documenter-source'>source</a><br>
231245

232246
<a id='TupleTools.maximum' href='#TupleTools.maximum'>#</a>
233247
**`TupleTools.maximum`** &mdash; *Function*.
@@ -241,7 +255,7 @@ maximum(t::Tuple)
241255
Returns the largest element of a tuple
242256

243257

244-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L172-L176' class='documenter-source'>source</a><br>
258+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L172-L176' class='documenter-source'>source</a><br>
245259

246260
<a id='TupleTools.findmin' href='#TupleTools.findmin'>#</a>
247261
**`TupleTools.findmin`** &mdash; *Function*.
@@ -255,7 +269,7 @@ findmin(t::Tuple)
255269
Returns the value and index of the minimum element in a tuple. If there are multiple minimal elements, then the first one will be returned.
256270

257271

258-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L198-L203' class='documenter-source'>source</a><br>
272+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L196-L201' class='documenter-source'>source</a><br>
259273

260274
<a id='TupleTools.findmax' href='#TupleTools.findmax'>#</a>
261275
**`TupleTools.findmax`** &mdash; *Function*.
@@ -269,7 +283,7 @@ findmax(t::Tuple)
269283
Returns the value and index of the maximum element in a tuple. If there are multiple maximal elements, then the first one will be returned.
270284

271285

272-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L215-L220' class='documenter-source'>source</a><br>
286+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L213-L218' class='documenter-source'>source</a><br>
273287

274288
<a id='TupleTools.argmin' href='#TupleTools.argmin'>#</a>
275289
**`TupleTools.argmin`** &mdash; *Function*.
@@ -283,7 +297,7 @@ argmin(t::Tuple)
283297
Returns the index of the minimum element in a tuple. If there are multiple minimal elements, then the first one will be returned.
284298

285299

286-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L181-L186' class='documenter-source'>source</a><br>
300+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L180-L185' class='documenter-source'>source</a><br>
287301

288302
<a id='TupleTools.argmax' href='#TupleTools.argmax'>#</a>
289303
**`TupleTools.argmax`** &mdash; *Function*.
@@ -297,7 +311,7 @@ argmax(t::Tuple)
297311
Returns the index of the maximum element in a tuple. If there are multiple minimal elements, then the first one will be returned.
298312

299313

300-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L190-L195' class='documenter-source'>source</a><br>
314+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L188-L193' class='documenter-source'>source</a><br>
301315

302316
<a id='TupleTools.sort' href='#TupleTools.sort'>#</a>
303317
**`TupleTools.sort`** &mdash; *Function*.
@@ -311,7 +325,7 @@ sort(t::Tuple; lt=isless, by=identity, rev::Bool=false) -> ::Tuple
311325
Sorts the tuple `t`.
312326

313327

314-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L234-L238' class='documenter-source'>source</a><br>
328+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L230-L234' class='documenter-source'>source</a><br>
315329

316330
<a id='TupleTools.sortperm' href='#TupleTools.sortperm'>#</a>
317331
**`TupleTools.sortperm`** &mdash; *Function*.
@@ -325,7 +339,7 @@ sortperm(t::Tuple; lt=isless, by=identity, rev::Bool=false) -> ::Tuple
325339
Computes a tuple that contains the permutation required to sort `t`.
326340

327341

328-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L260-L265' class='documenter-source'>source</a><br>
342+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L261-L266' class='documenter-source'>source</a><br>
329343

330344
<a id='TupleTools.isperm' href='#TupleTools.isperm'>#</a>
331345
**`TupleTools.isperm`** &mdash; *Function*.
@@ -339,7 +353,7 @@ isperm(p) -> ::Bool
339353
A non-allocating alternative to Base.isperm(p) that is much faster for small permutations.
340354

341355

342-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L307-L311' class='documenter-source'>source</a><br>
356+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L295-L299' class='documenter-source'>source</a><br>
343357

344358
<a id='TupleTools.invperm' href='#TupleTools.invperm'>#</a>
345359
**`TupleTools.invperm`** &mdash; *Function*.
@@ -353,7 +367,7 @@ invperm(p::NTuple{N,Int}) -> ::NTuple{N,Int}
353367
Inverse permutation of a permutation `p`.
354368

355369

356-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L323-L327' class='documenter-source'>source</a><br>
370+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L311-L315' class='documenter-source'>source</a><br>
357371

358372
<a id='TupleTools.permute' href='#TupleTools.permute'>#</a>
359373
**`TupleTools.permute`** &mdash; *Function*.
@@ -367,5 +381,5 @@ permute(t::Tuple, p) -> ::Tuple
367381
Permute the elements of tuple `t` according to the permutation in `p`.
368382

369383

370-
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/a898092ea5bed41dd20e64ef8e6d7010b2e12d64/src/TupleTools.jl#L296-L300' class='documenter-source'>source</a><br>
384+
<a target='_blank' href='https://github.com/Jutho/TupleTools.jl/blob/ebd92dd11b34ed902f88c9c6a4e61bbadf3c3a19/src/TupleTools.jl#L281-L285' class='documenter-source'>source</a><br>
371385

docs/make.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
using Documenter, TupleTools
1+
using Documenter, DocumenterMarkdown, TupleTools
22

3-
makedocs(modules=[TupleTools])
3+
makedocs(modules=[TupleTools],
4+
sitename="TupleTools.jl",
5+
authors = "Jutho Haegeman",
6+
format = DocumenterMarkdown.Markdown(),
7+
pages = [
8+
"Home" => "index.md",
9+
])

0 commit comments

Comments
 (0)