I have a function that takes in 2 tables and outputs the score and state of one table:
// tableOne tableTwo -> Score tableOne
fGetOutput:{[one;two]
...
?[scoreone >= scoretwo; (scoreone, tableOne); (scoretwo, tableTwo)]}
I also have a function that slightly modifies the contents of a table:
// table -> table
fAddRow:{[table]
...
table}
I want to loop the two of those and get the output at each iteration, so for example, this is what it would look like in pseudocode:
x=0
while x < 10,000:
output: fGetOutput[tableOne, tableTwo];
print("Loop # " + x, output[0], output[1]);
fAddRow;
x+=1
As this loop runs, I'll get the following output:
Loop #1 Score: 100, Table: ....
Loop #2 Score: 150, Table: ....
Loop #3 Score: 124, Table: ....
...
How do I do the above in q? I know there's the Do Accumulator, but I don't think it allows for the functionality above. Is there another way that I can accomplish getting the output?
You could achieve it as an extension of the accumulator
\
as per your other question: kdb/Q How to iterate on a function x number of times?But note that this would get very expensive and memory-hungry if you need to retain the outputs at every step.