# apply the function, pass the return value to the function again, multiple rounds

**URL:** https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/12495
**Category:** Community Support
**Tags:** kdb-and-q
**Created:** [April 16, 2022, 11:44pm UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/12495 "2022-04-16T23:44:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Matt\_Fang1](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Matt\_Fang1](https://forum.kx.com/u/Matt_Fang1)
#### Post date: [April 16, 2022, 11:44pm UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/12495/1 "2022-04-16T23:44:00Z")

</div>

I have a list of symbols, say `A`B`C. I have a table&nbsp;tab0; A function that takes in a table plus a string as arguments.

```
tab1: f[tab0;`A] tab2: f[tab1;`B] tab3: f[tab2;`C]

```

I only care about the final values. But my list of symbols can be long and can have variable length, so I don’t want to hardcode above. How do I achieve it?

I think it has something to do with&nbsp;https://code.kx.com/q/ref/accumulators/&nbsp;but I really struggle to figure out the syntax.

---

<div class="post-metadata">

### Author: ![rocuinneagain1](https://avatars.discourse-cdn.com/v4/letter/r/fbc32d/32.png) [@rocuinneagain1](https://forum.kx.com/u/rocuinneagain1)
#### Post date: [April 17, 2022, 11:08am UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/12495/2 "2022-04-17T11:08:00Z")

</div>

You can so this using&nbsp;over&nbsp;

q)tab:( A:1 2 3;B:4 5 6;C:7 8 9) // Sample table q)tab A B C ----- 1 4 7 2 5 8 3 6 9 q)func:{![x;();0b;enlist[y]!enlist (+;y;1)]} //Function I want to run q)func[tab;`A] // Same as: update A:A+1 from tab A B C ----- 2 4 7 3 5 8 4 6 9 q)func over enlist[tab],`A`B`C // Using over accumulator A B C ------ 2 5 8 3 6 9 4 7 10

&nbsp;

&nbsp;

&nbsp;
