Do you mean like *a, b, c = 1:3*
*string((1:3)...)* Ivar kl. 15:15:58 UTC+1 fredag 7. mars 2014 skrev Yuuki Soho følgende: > > It's a bit of a stupid question, but I don't really know how to deal with > this efficiently. > > So, in many application I have some model with parameters, and I want to > the able to change the number of parameters, or they order easily. > > For passing parameters to functions I want to pack them into a vector p, > such that I don't have huge function definition, but inside > > the function's body I'd prefer to have all the parameters given by their > name, so I can use them in equations (instead of using p[1], p[2], ...). > > > I can write two functions p = pack(a,b,c) and (a,b,c) = unpack(p) but > that's pretty restrictive because if you add or remove a parameters, I have > to change all > > my function calls and definition. If I add another model I also need to > write another pack and unpack pairs. > > > Is there an better approach to do this in Julia ? I was thinking maybe > doing a macro @unpack p that would spawn all the variables needed, but I'm > not > > sure that's the right way to do it. >
