Convert String to function name

Yes, that’s right. $(Symbol(i,j)) constructs the combined symbol and then substitutes it into the code to evaluate, which is what you want.

In contrast, @eval Symbol($i,$j)() = 0 is equivalent to writing Symbol(a,d)() = 0, which is not what you wanted.

Defining a bunch of functions from concatenated symbols in this way is actually pretty common in Julia, typically for writing wrapper code around external C and Fortran libraries that have lots of copy-and-paste permutations of a few symbols.

PS. Please read PSA: how to quote code with backticks

2 Likes