运行 在 table 上递归运行

run function recursively over table

每次调用函数 fx 都会根据 table t 中的一些数据和整数 pq
我在下面显示了对 pq 值的期望迭代,但不知道如何使用 KDB+ 迭代器正确地进行迭代。
示例数据和解决方案:

x:([]date:(2013.07.01+til 10);ords:til 10); /Some random table with date (key column)
t:p:([]date:(2013.07.01+1000#til 200);px:1000?10e); /Some random table.
fx:{[x;t;p;q]
    /Do something with t;p;q and left-join output column to x on date;
    t:([]date:(2013.07.01+til 10);ords:10?10000);
    col_names:(`date;`$""sv(string(`P);string(p);string(`Q);string(q)));
    t: x lj 1!col_names xcol t;
    :t
    };

/Run simulation for p=1 to 2 and q=3 to 4 as follows:
fx[ fx[ fx[ fx[x;t;1;3]; t;2;3]; t;1;4]; t;2;4] /How to do this iteration properly?

最后一条语句在 pq 上有两个 for 循环,分别来自 1to2 和 3to4。我确信使用 scan/over 有更好的方法来实现此目的,但我无法弄清楚。有人可以帮忙吗

我们可以将 t 作为投影传递,因为它在每次迭代中保持不变,然后对其他变量使用扫描迭代

fx[;t;;]/[x;1 2 1 2;3 3 4 4]