【发布时间】:2021-03-27 16:05:24
【问题描述】:
我正在尝试从嵌套表中删除一组项目;例如给出下表
tree:{[t;col]
if[1=count col; :![t;();0b;enlist[`name]!col]];
f:first col;
c:cols[t] except f;
r:1_col;
:?[t;();(enlist `name)!enlist f ;`val`child!((sum;`val);({[r;c;l] tree[flip c!l;r]};enlist r;enlist c;(enlist, c )))]
};
t:flip`cat`dog`caps`val`val1!flip((cross/)(0 1;`$(5 1)#.Q.a;`$(5 1)#.Q.A;til 5;5+til 5));
// derive tree from aforementioned table
tre:tree[t;`cat`dog`caps];
// notably returns correct result indexed by name
.[tre;(0;`child)] enlist[`name]!enlist[`a`b`c];
// does not work ???
.[tre;(0;`child);_;enlist[`name]!enlist[`a`b`c]];
我曾想过使用以下方法作为解决方案
.[tre;(0;`child);{delete from y where name in x}[`a`b`c]];
我只是想检查是否有更简洁(普遍接受)的方法。比如使用 enlist[name]!enlist[abc];索引来实现这一点。
在 KDB+ 中,应该如何从嵌套树中适当地删除一组给定的索引? 感谢您的指导。
【问题讨论】:
标签: kdb