[julia-users] Re: Should `append!(a::Vector{T}, items::NTuple{N, T})` be defined in Base?

2016-04-13 Thread Davide Lasagna
Interestingly, I have just noticed a bug in append!, see 
https://github.com/JuliaLang/julia/issues/15868

It occurs when you try to append a vector of elements which have a 
different type with respect to that of the original vector and when the 
conversion mechanism fails.

On Wednesday, April 13, 2016 at 11:44:29 PM UTC+1, Steven G. Johnson wrote:
>
>
>
> On Wednesday, April 13, 2016 at 6:22:27 PM UTC-4, Greg Plowman wrote:
>>
>> Considering the existing append! is pretty loose wrt the items being 
>> appended, a simple extension to the signature might work:
>>
>> append!{T}(a::Array{T,1}, items::Union{AbstractVector,Tuple})
>>
>
> Arguably, the signature should be append!(a::AbstractVector, itr), i.e. 
> you should be able to append any iterable object.
>


[julia-users] Re: Should `append!(a::Vector{T}, items::NTuple{N, T})` be defined in Base?

2016-04-13 Thread Steven G. Johnson


On Wednesday, April 13, 2016 at 6:22:27 PM UTC-4, Greg Plowman wrote:
>
> Considering the existing append! is pretty loose wrt the items being 
> appended, a simple extension to the signature might work:
>
> append!{T}(a::Array{T,1}, items::Union{AbstractVector,Tuple})
>

Arguably, the signature should be append!(a::AbstractVector, itr), i.e. you 
should be able to append any iterable object.


[julia-users] Re: Should `append!(a::Vector{T}, items::NTuple{N, T})` be defined in Base?

2016-04-13 Thread 'Greg Plowman' via julia-users
Considering the existing append! is pretty loose wrt the items being 
appended, a simple extension to the signature might work:

append!{T}(a::Array{T,1}, items::Union{AbstractVector,Tuple})


You could extend this yourself to try it out.


On Thursday, April 14, 2016 at 4:07:45 AM UTC+10, Davide Lasagna wrote:

> Hi all,
>
> I need to extend a vector with contents from n-tuples i generate 
> iteratively. Currently 
>
> append!(a::Vector{T}, items::NTuple{N, T})
>
> is not defined, whereas the method 
>
> append!{T}(a::Array{T,1}, items::AbstractVector)
>
> exists and is defined in array.jl. 
>
> Anyone finds this useful to justify opening a pull request? What would be 
> a good implementation?
>