Home > Software design >  How to collect an iterator into an exiting container?
How to collect an iterator into an exiting container?

Time:07-27

If I have a iterators, say a=1:10 and an array that I've already allocated (x = zeros(10)), how can I collect my array into the container without allocating a new array?

E.g. does something like collect!(x, a) exist?

CodePudding user response:

copyto!(x, 1:10)

Filling the void here to 30 characters

  • Related