You must splat if you use push!

You must _not_ splat if you use append!

 -- John

On Jul 24, 2014, at 11:10 AM, [email protected] wrote:

> Even splatting does not seem to work. 
> My error message is now 
> ERROR: no method append!(Array{Float64,1},Float64,Float64,Float64,Float64)
> Do I need to use a different sort of array? 
> 
> On Thursday, July 24, 2014 12:48:15 PM UTC-4, Jameson wrote:
> Yes
> 
> Or use append! instead of push!
> 
> 
> On Thursday, July 24, 2014, <[email protected]> wrote:
> Ah, is ... equivalent to the * in Python? 
> 
> On Thursday, July 24, 2014 12:40:12 PM UTC-4, John Myles White wrote:
> You need to splat the tuple first: 
> 
> push!(tuplestorage,newtuple...) 
> 
>  -- John 
> 
> On Jul 24, 2014, at 9:38 AM, [email protected] wrote: 
> 
> > Hi, 
> > Translating some of my code from Python, I am trying to find a means of 
> > concatenating and appending tuples to an array. 
> > 
> > In Python, I was able to do this: 
> > 
> > def createtuplelist: 
> >     tuplestorage = [] 
> >     for i in range(iteration): 
> >         newtuple = foo(i) 
> >         tuplestorage.append(newtuple) 
> >     return tuplestorage 
> > 
> > In Julia, I have tried to this so far: 
> > function createtuplearray 
> >     tuplestorage = Float64[] 
> >     for i in Int64[1:iteration] 
> >         newtuple = foo(i) 
> >         push!(tuplestorage,newtuple) 
> >     return tuplestorage 
> > end 
> > 
> > However, doing this in Julia returns the error message ERROR: no method 
> > convert(Type{Float64},(Float64,Float64,Float64,Float64))in push! at 
> > array.jl:659. 
> > Is it possible to append tuples to an array in Julia? 
> 

Reply via email to