First, you probably would be better off with an array, rather than 100 
variables with numeric postfixes. You can use push!() for this.

Second, the error is because Julia is trying to parse the left hand side as 
an attempt to define a function, using the shortened f(x) = y function 
definition syntax. Here, f is *, and the literal `"m" * string(i)` is being 
interpreted as the name of its argument, but this is not a valid identifier.

Finally, although you almost certainly don't want to do what you're trying 
to do, you can if you separate creation of the symbol from evaluation:

var_name = symbol("m" * string(i))
@eval $var_name = readcsv(string("m", i, ".txt"))

On Wednesday, June 4, 2014 11:36:37 AM UTC-5, paul analyst wrote:
>
> dynamic creation and naming of variables, what wrong?
>
> I need 100 new variables : m1 to m 100
>
> julia> for i=1:100
>        "m" * string(i)=readcsv(string("m",i,".txt"))
>        end
> ERROR: syntax: "#<julia_value>" is not a valid function argument name
>

Reply via email to