Search code examples
kdb

KDB/Q sequence generation similar to R's seq(from, to, step)


Is there a way to generate sequence of number with a given step, similar to R's seq(from, to, step) function?

e.g.

> seq(1,20,2)   
[1]  1  3  5  7  9 11 13 15 17 19

Solution

  • user2393012's answer is close, but not exactly what question was looking for. The below works well -

    q)seq:{x+z*til ceiling(1+y-x)%z}
    q)seq[1;20;2]
    1 3 5 7 9 11 13 15 17 19