Skip to content

Commit f2f2351

Browse files
author
Michael Abbott
committed
readme
1 parent befd85b commit f2f2351

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This package exports one function, `stack`, for turning a list of arrays
66
into one `AbstractArray`. Given several arrays with the same `eltype`,
7-
or an array of such arrays, it returns a lazy `Stacked{T,N}` view of these.
7+
or an array of such arrays, it returns a lazy `Stacked{T,N}` view of these:
88

99
```julia
1010
stack([zeros(2,2), ones(2,2)]) # isa Stacked{Float64, 3, <:Vector{<:Matrix}}
@@ -13,18 +13,22 @@ stack([1,2,3], 4:6) # isa Stacked{Int, 2, <:Tuple{<:Vector, <:UnitRa
1313

1414
Given a generator, it instead iterates through the elements and writes into a new array.
1515
Given a function and then some arrays, it behaves like `map(f, A, B)` but immediately writes
16-
the into a new array.
17-
The same `stack_iter` method is also used for any list of arrays of heterogeneous element type.
16+
into a new array:
1817

1918
```julia
2019
stack([i,2i] for i in 1:5) # isa Matrix{Int} # size(ans) == (2, 5)
2120
stack(*, eachcol(ones(2,4)), 1:4) # == Matrix(stack(map(*, eachcol(...), 1:4)))
22-
stack([1,2], [3.0, 4.0], [5im, 6im]) # isa Matrix{Number} # size(ans) == (2, 3)
2321
```
2422

25-
Notice that like `map(identity, Any[1, 1.0, 5im])`, this promotes using
23+
The same `stack_iter` method is also used for any list of arrays of heterogeneous element type,
24+
and for arrays of tuples. Notice that like `map(identity, Any[1, 1.0, 5im])`, this promotes using
2625
`promote_typejoin`, to `Number` here, rather than to `Complex{Float64}`.
2726

27+
```julia
28+
stack([1,2], [3.0, 4.0], [5im, 6im]) # isa Matrix{Number} # size(ans) == (2, 3)
29+
stack([(1,2.0,3//1) for i=1:4, j=1:5])# isa Array{Real, 3} # size(ans) == (3, 4, 5)
30+
```
31+
2832
The slices must all have the same `size`, but they (and the container)
2933
can have any number of dimensions. `stack` always places the slice dimensions first.
3034
There are no options.

0 commit comments

Comments
 (0)