Using @turbo and remaining agnostic about variable names

Hi all,

right now, I specify the variables:

 @turbo for j in axes(delta, 1), k in axes(delta, 2)
    delta[j, k] +=  exp(nu_alpha[k] + price[j]*nu_p[k] + x_j[j]*nu_xj[k] +
    x_r[j]*nu_xr[k] + x_m[j]*nu_xm[k] +xi[j])

where my variables are price, x_j, x_r, x_m and xi.

I am wondering how I can remain agnostic about the variable names. One way would be to create a vector of strings, variables = [“price”,“x_j”,“x_r”,“x_m”] and use it to subset the data “dt”, stacking nu’s.

delta = exp.(dt[:,variables] * nu_stacked + xi)

But now, I am losing the speed advantage of @turbo. Any ideas how to keep the speed advantage?

Put this in a function. Then you can call that function with different arrays.