# rank error when calling a nested function.

**URL:** <https://forum.kx.com/t/rank-error-when-calling-a-nested-function/8603>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [January 29, 2014, 8:11pm UTC](https://forum.kx.com/t/rank-error-when-calling-a-nested-function/8603 "2014-01-29T20:11:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iurgasndiff](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@iurgasndiff](https://forum.kx.com/u/iurgasndiff)\
**Post date:** [January 29, 2014, 8:11pm UTC](https://forum.kx.com/t/rank-error-when-calling-a-nested-function/8603/1 "2014-01-29T20:11:00Z")

</div>

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 &nbsp; 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?&nbsp;

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [January 30, 2014, 5:36am UTC](https://forum.kx.com/t/rank-error-when-calling-a-nested-function/8603/2 "2014-01-30T05:36:00Z")

</div>

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 &nbsp; 5 &nbsp; &nbsp;
