Hello,
On 7 March 2016 at 15:04, Tom Breloff <[email protected]> wrote: > I have to wonder... why are you writing collect(1:10) so much? I almost > never use that pattern, as it's much better to keep the range as-is (it's > just as good as an Array, without the memory usage). > Hmm... You got me thinking. So I went back through my code and looked at every place where I use collect(). Indeed, in many places I could just drop the "collect" and use a range instead. After some code clean up, I am left with places where I want to do array operations. For example: im = ones(5)*collect(0:0.01:1)' In the process, I found that you can do some arithmetic operations on ranges! You can also do concatenations! For example: 7 * 1:0.005:7 + 10 [0.5:0.1:1; 2:10; 20] That's two examples of the sort of thing I was doing where I thought I needed collect() but didn't. So in conclusion, I really was overusing collect(). Incidentally, if there is a way to avoid collect() for a matrix operation, I'd love to know. Cheers, Daniel.
