Hi, I would like to use N loops in a script for an arbitrary number of 
loops using Cartesian. Do you know if that is possible?

E.g. : 


julia> using Cartesian

julia> it=[-1.,0.,1.]
3-element Array{Float64,1}:
 -1.0
  0.0
  1.0




julia> @nloops 3 i d->it begin
          tp = @ntuple 3 i
          println(tp)
          end
(-1.0,-1.0,-1.0)
(0.0,-1.0,-1.0)
(1.0,-1.0,-1.0)
(-1.0,0.0,-1.0)
(0.0,0.0,-1.0)
(1.0,0.0,-1.0)
(-1.0,1.0,-1.0)
(0.0,1.0,-1.0)
(1.0,1.0,-1.0)
(-1.0,-1.0,0.0)
(0.0,-1.0,0.0)
(1.0,-1.0,0.0)
(-1.0,0.0,0.0)
(0.0,0.0,0.0)
(1.0,0.0,0.0)
(-1.0,1.0,0.0)
(0.0,1.0,0.0)
(1.0,1.0,0.0)
(-1.0,-1.0,1.0)
(0.0,-1.0,1.0)
(1.0,-1.0,1.0)
(-1.0,0.0,1.0)
(0.0,0.0,1.0)
(1.0,0.0,1.0)
(-1.0,1.0,1.0)
(0.0,1.0,1.0)
(1.0,1.0,1.0)






However

julia> N=3
3

julia> @nloops N i d->it begin
                 tp = @ntuple N i
                 println(tp)
                 end
ERROR: `_nloops` has no method matching _nloops(::Symbol, ::Symbol, ::Expr, 
::Expr)


Is it possible to modify nloops so that it takes a variable for the number 
of loops?

Thanks and best wishes,
Georgios

Reply via email to