You can do view(r, :, i_2) in 0.5. I think slice does the same thing in 0.4.

Also as a general point, you would have realized you hadn't defined r in 
the function if you had wrapped your entire program in a function, like
function test()
(your code)
end
test()
This would throw an error with your original code since r would not be in 
scope in nested_loop!().

I occasionally have accidentally used outside global variables in my 
functions like you did, and this can lead to bizarre and difficult to find 
bugs.

On Tuesday, October 4, 2016 at 8:45:53 AM UTC-4, Niccolo' Antonello wrote:
>
> what is the best way to slice an array without allocating? I thank you!
>
> On Tuesday, October 4, 2016 at 1:20:29 PM UTC+2, Kristoffer Carlsson wrote:
>>
>> The slicing of "r" will also make a new array and thus allocate. 
>
>

Reply via email to