julia> itr = randn(10)
10-element Array{Float64,1}:
 -0.385614
  0.675975
  0.221349
  0.188755
 -0.235969
 -1.65408
 -0.155242
 -2.03179
  0.681808
  0.403859

julia> @task for x in itr produce(x) end
Task (runnable) @0x00007f8b918eb5c0

julia> collect(ans)
10-element Array{Any,1}:
 -0.385614
  0.675975
  0.221349
  0.188755
 -0.235969
 -1.65408
 -0.155242
 -2.03179
  0.681808
  0.403859

It's a wrapper, yes, but it's very lightweight :-)


On Sun, Feb 16, 2014 at 7:00 PM, andrew cooke <[email protected]> wrote:

> i need to pass an array to a function that is expecting a Task (and which
> repeatedly calls consume(...) on the argument).  is there a standard way of
> converting an array to a generator?  seems like this should be easy and
> something i've done before, but i'm stuck (obviously i can write my own
> little wrapper, but i assume there's a neat way to do this).
>
> thanks, andrew
>
>

Reply via email to