Reputation: 4716
How can I assign multiple local variables by names?
For example, within a lambda, something like this:
{
@[;:;] (.') flip (`a`b;4 2);
(a;b)
}[] / should return 4 2
But obviously does not work, because
q)@[`a;:;4]
'type
Also,
q):[`a`b;4 2]
'assign
and using set
:
q)set'[`a`b;4 2]
assigns to global, not local environment.
Upvotes: 2
Views: 523
Reputation: 520
I believe you'll have difficulty saving local variables this way without a hacky solution and without knowing the reason for it needing to be local it's hard to produce a solution that could help. However, here's some suggestions:
(!). (`a`b;4 2)
You can access local variables using
q){c:3;?[(`$())!();();0b;`c]}[]
3
but the problem here is the assigning of values to local variables.
Upvotes: 2