diff --git a/base/array.jl b/base/array.jl index 64189afa33219..27203f5305957 100644 --- a/base/array.jl +++ b/base/array.jl @@ -362,6 +362,8 @@ Create an array of all zeros with the same layout as `A`, element type `T` and s The `A` argument can be skipped, which behaves like `Array{Float64,0}()` was passed. For convenience `dims` may also be passed in variadic form. +See also: [`ones`](@ref), [`similar`](@ref) + # Examples ```jldoctest julia> zeros(1) @@ -394,7 +396,6 @@ julia> zeros(A, Bool, (3,)) false false ``` -See also [`ones`](@ref), [`similar`](@ref). """ function zeros end @@ -405,6 +406,8 @@ Create an array of all ones with the same layout as `A`, element type `T` and si The `A` argument can be skipped, which behaves like `Array{Float64,0}()` was passed. For convenience `dims` may also be passed in variadic form. +See also: [`zeros`](@ref), [`similar`](@ref) + # Examples ```jldoctest julia> ones(Complex128, 2, 3) @@ -437,7 +440,6 @@ julia> ones(A, Bool, (3,)) true true ``` -See also [`zeros`](@ref), [`similar`](@ref). """ function ones end @@ -883,6 +885,8 @@ _deleteat!(a::Vector, i::Integer, delta::Integer) = Insert one or more `items` at the end of `collection`. +See also: [`append!`](@ref), [`unshift!`](@ref), [`insert!`](@ref), [`pop!`](@ref) + # Examples ```jldoctest julia> push!([1, 2, 3], 4, 5, 6) @@ -894,10 +898,6 @@ julia> push!([1, 2, 3], 4, 5, 6) 5 6 ``` - -Use [`append!`](@ref) to add all the elements of another collection to -`collection`. The result of the preceding example is equivalent to `append!([1, 2, 3], [4, -5, 6])`. """ function push! end @@ -916,9 +916,11 @@ function push!(a::Array{Any,1}, @nospecialize item) end """ - append!(collection, collection2) -> collection. + append!(a::Vector, items) -> collection. -Add the elements of `collection2` to the end of `collection`. +Add the elements of `items` to the end of `a`. + +See also: [`push!`](@ref), [`prepend!`](@ref), [`insert!`](@ref) # Examples ```jldoctest @@ -927,20 +929,7 @@ julia> append!([1],[2,3]) 1 2 3 - -julia> append!([1, 2, 3], [4, 5, 6]) -6-element Array{Int64,1}: - 1 - 2 - 3 - 4 - 5 - 6 ``` - -Use [`push!`](@ref) to add individual items to `collection` which are not already -themselves in another collection. The result is of the preceding example is equivalent to -`push!([1, 2, 3], 4, 5, 6)`. """ function append!(a::Array{<:Any,1}, items::AbstractVector) itemindices = eachindex(items) @@ -974,6 +963,8 @@ end Insert the elements of `items` to the beginning of `a`. +See also: [`unshift!`](@ref), [`append!`](@ref), [`insert!`](@ref) + # Examples ```jldoctest julia> prepend!([3],[1,2]) @@ -1080,6 +1071,8 @@ end Remove an item in `collection` and return it. If `collection` is an ordered container, the last item is returned. +See also: [`shift!`](@ref), [`splice!`](@ref), [`push!`](@ref) + # Examples ```jldoctest julia> A=[1, 2, 3] @@ -1123,16 +1116,18 @@ end Insert one or more `items` at the beginning of `collection`. +See also: [`prepend!`](@ref), [`push!`](@ref), [`insert`](@ref), [`shift!`](@ref) + # Examples ```jldoctest -julia> unshift!([1, 2, 3, 4], 5, 6) +julia> unshift!([1, 2, 3], 4, 5, 6) 6-element Array{Int64,1}: + 4 5 6 1 2 3 - 4 ``` """ function unshift!(a::Array{T,1}, item) where T @@ -1147,6 +1142,8 @@ end Remove the first `item` from `collection`. +See also: [`pop!`](@ref), [`splice!`](@ref), [`unshift!`](@ref) + # Examples ```jldoctest julia> A = [1, 2, 3, 4, 5, 6] @@ -1185,6 +1182,8 @@ end Insert an `item` into `a` at the given `index`. `index` is the index of `item` in the resulting `a`. +See also: [`push!`](@ref), [`unshift!`](@ref), [`splice!`](@ref) + # Examples ```jldoctest julia> insert!([6, 5, 4, 2, 1], 4, 3) @@ -1212,6 +1211,8 @@ end Remove the item at the given `i` and return the modified `a`. Subsequent items are shifted to fill the resulting gap. +See also: [`splice!`](@ref), [`pop!`](@ref), [`unshift!`](@ref) + # Examples ```jldoctest julia> deleteat!([6, 5, 4, 3, 2, 1], 2) @@ -1316,6 +1317,8 @@ Subsequent items are shifted left to fill the resulting gap. If specified, replacement values from an ordered collection will be spliced in place of the removed item. +See also: [`pop!`](@ref), [`shift!`](@ref), [`insert!`](@ref), [`deleteat!`](@ref) + # Examples ```jldoctest splice! julia> A = [6, 5, 4, 3, 2, 1]; splice!(A, 5) @@ -1353,9 +1356,6 @@ julia> A 3 -1 ``` - -To insert `replacement` before an index `n` without removing any items, use -`splice!(collection, n:n-1, replacement)`. """ function splice!(a::Vector, i::Integer, ins=_default_splice) v = a[i]