# function within function

**URL:** <https://forum.kx.com/t/function-within-function/6849>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [January 5, 2011, 3:29am UTC](https://forum.kx.com/t/function-within-function/6849 "2011-01-05T03:29:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![effbiae](https://avatars.discourse-cdn.com/v4/letter/e/ecae2f/32.png) [@effbiae](https://forum.kx.com/u/effbiae)\
**Post date:** [January 5, 2011, 3:29am UTC](https://forum.kx.com/t/function-within-function/6849/1 "2011-01-05T03:29:00Z")

</div>

q){(update b:99 from x){[x;y]update b:y from x}0} flip `a`b!2 3# til 4  
{(update b:99 from x){[x;y]update b:y from x}0}  
'type  
@  
+`a`b!(0 1 2;99 99 99)  
{[x;y]update b:y from x}[0]

it appears that q doesn’t see (update b:99 from x) as  
an x-value and, instead, takes 0 as the x-value.  
any tips for better style?

ta, jack.

---

<div class="post-metadata">

**Author:** ![junan\_duan](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@junan\_duan](https://forum.kx.com/u/junan_duan)\
**Post date:** [January 5, 2011, 4:46am UTC](https://forum.kx.com/t/function-within-function/6849/2 "2011-01-05T04:46:00Z")

</div>

how about??  
? ? ? ? ? { {[x;y]update b:y from x}[update b:99 from x;0]} flip `a`b!2 3# til 4

Junan

---

<div class="post-metadata">

**Author:** ![Aaron\_Davies](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Aaron\_Davies](https://forum.kx.com/u/Aaron_Davies)\
**Post date:** [January 5, 2011, 5:01am UTC](https://forum.kx.com/t/function-within-function/6849/3 "2011-01-05T05:01:00Z")

</div>

yes, infix isn’t available in general for user-created functions, only  
for things in the .q namespace and for invocations involving adverbs.

the original code applies 0 to the dyadic inner function, returning a  
projection, which is then “applied” to the table resulting from the  
outer update, which results in the type error.
