# 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/13490>\
**Category:** Community Support\
**Tags:** imported, kdb-and-q\
**Created:** [April 16, 2022, 12:00am UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/13490 "2022-04-16T00:00:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matt\_fang](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@matt\_fang](https://forum.kx.com/u/matt_fang)\
**Post date:** [April 16, 2022, 12:00am UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/13490/1 "2022-04-16T00:00:00Z")

</div>

[https://learninghub.kx.com/forums/topic/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds](https://learninghub.kx.com/forums/topic/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds)

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

```auto
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 [https://code.kx.com/q/ref/accumulators/](https://code.kx.com/q/ref/accumulators/") but I really struggle to figure out the syntax.

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [April 17, 2022, 12:00am UTC](https://forum.kx.com/t/apply-the-function-pass-the-return-value-to-the-function-again-multiple-rounds/13490/2 "2022-04-17T00:00:00Z")

</div>

You can so this using [over](https://code.kx.com/q/ref/over/")

```
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;
