Re: [julia-users] fill! with copies

2014-05-18 Thread Carlos Becker
Thanks all, those look like neat solutions. -- Carlos On Fri, May 16, 2014 at 11:36 PM, Stefan Karpinski ste...@karpinski.orgwrote: When you write fill!(arr, ChannVals()) you are asking to fill arr with the one value that is the result of evaluating

[julia-users] fill! with copies

2014-05-16 Thread Carlos Becker
Hello all, I wanted to create an array of an immutable type and initialize an empty copy in each (with the default constructor). I am wondering which is the best way to do it, so far: immutable ChannVals taus::Vector{Float64} alphas::Vector{Float64} ChannVals() = new( Float64[], Float64[] )

Re: [julia-users] fill! with copies

2014-05-16 Thread Carlos Becker
* correction, 'allVals' is 'arr' in the last line of code. -- Carlos On Fri, May 16, 2014 at 10:27 AM, Carlos Becker carlosbec...@gmail.comwrote: Hello all, I wanted to create an array of an immutable type and initialize an empty copy in each (with

Re: [julia-users] fill! with copies

2014-05-16 Thread Tim Holy
Try arr = [ChannVals() for i = 1:10] On Friday, May 16, 2014 01:27:18 AM Carlos Becker wrote: Hello all, I wanted to create an array of an immutable type and initialize an empty copy in each (with the default constructor). I am wondering which is the best way to do it, so far:

Re: [julia-users] fill! with copies

2014-05-16 Thread Jameson Nash
Since they are immutable, fill! did exactly what you wanted On Friday, May 16, 2014, Tim Holy tim.h...@gmail.com wrote: Try arr = [ChannVals() for i = 1:10] On Friday, May 16, 2014 01:27:18 AM Carlos Becker wrote: Hello all, I wanted to create an array of an immutable type and

Re: [julia-users] fill! with copies

2014-05-16 Thread Ivar Nesje
@Jameson They are immutable, but they contain references to mutable arrays, and all the immutable types will reference the same arrays. That way you would not just need a copy but a deepcopy. That will probably be too much overhead for fill!(), and will be problematic if someone decided to