Home › Forums › kdb+ › apply the function, pass the return value to the function again, multiple rounds › Re: apply the function, pass the return value to the function again, multiple rounds
-
You can so this using 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