Skip to content

Commit 0fc0ead

Browse files
committed
Update docs
1 parent 85429ee commit 0fc0ead

File tree

4 files changed

+72
-18
lines changed

4 files changed

+72
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
docs/build

README.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
# TupleTools.jl
55

66

7-
[![Build Status](https://travis-ci.org/Jutho/TupleTools.jl.svg?branch=master)](https://travis-ci.org/Jutho/TupleTools.jl)
8-
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md)
9-
[![Coverage Status](https://coveralls.io/repos/Jutho/TupleTools.jl/badge.svg?branch=master&service=github)](https://coveralls.io/github/Jutho/TupleTools.jl?branch=master)
10-
[![codecov.io](http://codecov.io/github/Jutho/TupleTools.jl/coverage.svg?branch=master)](http://codecov.io/github/Jutho/TupleTools.jl?branch=master)
7+
[![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)
118

129

13-
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 inferrable 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`. Inference also breaks down for most methods in case of inhomogeneous tuples.
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 inferrable 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.
1411

1512

1613
<a id='Types-1'></a>
@@ -87,6 +84,29 @@ getindices(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
8784

8885
Get the indices `t[i] for i in I`, again as tuple.
8986

87+
<a id='TupleTools.deleteat' href='#TupleTools.deleteat'>#</a>
88+
**`TupleTools.deleteat`** &mdash; *Function*.
89+
90+
91+
92+
```
93+
deleteat(t::Tuple, i::Int) -> ::Tuple
94+
deleteat(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
95+
```
96+
97+
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.
98+
99+
<a id='TupleTools.insertat' href='#TupleTools.insertat'>#</a>
100+
**`TupleTools.insertat`** &mdash; *Function*.
101+
102+
103+
104+
```
105+
insertat(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
106+
```
107+
108+
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`.
109+
90110
<a id='TupleTools.vcat' href='#TupleTools.vcat'>#</a>
91111
**`TupleTools.vcat`** &mdash; *Function*.
92112

@@ -98,28 +118,37 @@ vcat(args...) -> ::Tuple
98118

99119
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.
100120

101-
<a id='TupleTools.deleteat' href='#TupleTools.deleteat'>#</a>
102-
**`TupleTools.deleteat`** &mdash; *Function*.
121+
<a id='TupleTools.sum' href='#TupleTools.sum'>#</a>
122+
**`TupleTools.sum`** &mdash; *Function*.
103123

104124

105125

106126
```
107-
deleteat(t::Tuple, i::Int) -> ::Tuple
108-
deleteat(t::Tuple, I::Tuple{Vararg{Int}}) -> ::Tuple
127+
sum(t::Tuple)
109128
```
110129

111-
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.
130+
Returns the sum of the element of a tuple, or `0` for an empty tuple.
112131

113-
<a id='TupleTools.insertat' href='#TupleTools.insertat'>#</a>
114-
**`TupleTools.insertat`** &mdash; *Function*.
132+
<a id='TupleTools.prod' href='#TupleTools.prod'>#</a>
133+
**`TupleTools.prod`** &mdash; *Function*.
115134

116135

117136

118137
```
119-
insertat(t::Tuple, i::Int, t2::Tuple) -> ::Tuple
138+
prod(t::Tuple)
120139
```
121140

122-
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. See `splice` if you would also like to return `t[i]`
141+
Returns the product of the elements of a tuple, or `1` for an empty tuple.
142+
143+
144+
```
145+
TupleTools.minimum
146+
TupleTools.maximum
147+
TupleTools.findmin
148+
TupleTools.findmax
149+
TupleTools.indmin
150+
TupleTools.indmax
151+
```
123152

124153
<a id='TupleTools.sort' href='#TupleTools.sort'>#</a>
125154
**`TupleTools.sort`** &mdash; *Function*.

docs/src/index.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ A bunch of tools for using tuples (mostly homogeneous tuples `NTuple{N}`) as a c
99
and performing a number of operations with an inferrable result, typically also an `NTuple{M}`
1010
with inferrable length `M`. Type inference breaks down if some of the final or intermediate tuples
1111
exceed `MAX_TUPLETYPE_LEN`, meaning inference typically works up to output tuples of
12-
length `13` or `14`. Inference also breaks down for most methods in case of inhomogeneous tuples.
12+
length `13` or `14`. Chosen implementations are typically faster than the corresponding functions
13+
in base for those small tuple lengths, but can be slower for larger tuples. Inference also breaks
14+
down for most functions in case of inhomogeneous tuples.
15+
16+
Note that none of the following functions are exported, since their name often collides with the equivalent from `Base`.
1317

1418
## Types
1519

@@ -27,12 +31,25 @@ TupleTools.unsafe_front
2731

2832
```@docs
2933
TupleTools.getindices
30-
TupleTools.vcat
3134
```
3235

3336
```@docs
3437
TupleTools.deleteat
3538
TupleTools.insertat
39+
TupleTools.vcat
40+
```
41+
```@docs
42+
TupleTools.sum
43+
TupleTools.prod
44+
```
45+
46+
```@docs
47+
TupleTools.minimum
48+
TupleTools.maximum
49+
TupleTools.findmin
50+
TupleTools.findmax
51+
TupleTools.indmin
52+
TupleTools.indmax
3653
```
3754

3855
```@docs

src/TupleTools.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ minimal elements, then the first one will be returned.
150150
"""
151151
indmin(t::Tuple) = findmin(t)[2]
152152

153+
154+
"""
155+
indmax(t::Tuple)
156+
157+
Returns the index of the maximum element in a tuple. If there are multiple
158+
minimal elements, then the first one will be returned.
159+
"""
160+
indmax(t::Tuple) = findmax(t)[2]
161+
153162
"""
154163
findmin(t::Tuple)
155164
@@ -173,8 +182,6 @@ end
173182
Returns the value and index of the maximum element in a tuple. If there are multiple
174183
maximal elements, then the first one will be returned.
175184
"""
176-
indmax(t::Tuple) = findmax(t)[2]
177-
178185
findmax(::Tuple{Any}) = 1
179186
findmax(t::Tuple) = _findmax(tail(t),2,t[1],1)
180187
@inline _findmax(t::Tuple{}, s, v, i) = (v, i)

0 commit comments

Comments
 (0)