向 kdb 中的列表元素添加索引

Adding Indexes to elements of a list in kdb

如何向列表的每个元素添加其索引,即向索引 0 处的元素添加 0,向索引 1 处的元素添加 1 等等。

我的列表是 list1:

 q)list1:3+20?30

使用 'til' 和 'count' 生成索引并将其添加到实际元素中。

 q) list1 + til count list1

til count list1 将生成列表的索引。

q) list1: 1 2 3
q) count list1  / 3
q) til count list1  / same as til count 3
q) 0 1 2