Search code examples
kdb

can I create a dictionary with the value is a list


I try to create a dictionary with the value is a list. the list is generated based on the key. For example, add 1 to the key and repeat 100 times.

0| 1 1 ...1 //a list with 100 "1" which is key(0)+1
1| 2 2 ...2
2| 3 3 ...3
3| 4 4 ...4

Can I do this in KDB?


Solution

  • {[lst;n]til[n]!lst+/:til n}[100#1;4]
    

    This function accepts the list and the number n you wish to go too. the /: is an adverb each-right which in this case is added each rhs parameter to the lhs parameter.