Hi Everyone,
I noticed a weird scenario relating to nested function call.
q)table:(sym:a
b`c;price:4 5 6)
q)func1:{[a;b] {[l;m]select from l where sym=m}[a;b]}
q)func2:{[a;b] {select from x where sym=y}[a;b]}
q)func1[table;
b]
sym price
b 5
q)func2[table;
b]
{[a;b] {select from x where sym=y}[a;b]}
'rank
q))
Could anybody tell me what’s wrong with func2? Why is it throwing 'rank error?
here x and y when used in a select are not detected as implicit args to the function,
and therefore the function is expecting only a single argument.
You can check which args are expected with
q)0N!value{[x;y]select from x where sym=y};
(0x0ba0a178a20a040005;x
y;symbol$();,
;0b;,(=;sym;
y);?;“{[x;y]select from x where sym=y}”)
q)0N!value{select from x where sym=y};
(0x0ba0a178a20a040005;,x</font>;
symbol$();,;0b;,(=;
sym;`y);?;“{select from x where sym=y}”)
Hence make those args explicit
q)func2:{[a;b] {[x;y]select from x where sym=y}[a;b]}
q)func2[table;
b]
sym price
b 5