for loop evil, but wanted - Kdb+ / qStudio

Home Forums Kdb+ / qStudio for loop evil, but wanted

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #132

    Johnny Chan
    Guest

    How do you write a for loop in kdb?

    I know loops are considered evil by you vector guys but sometimes the code really just requires a loop. I tried a few “for” combinations but couldn’t create one in kdb.

    #144

    John Dempster
    Keymaster

    the q language does not have a for loop. Other control statements are available. e.g.


    q)i:0; while[i<3; show i; i:i+1]; show `end
    0
    1
    2
    `end
    q)i
    3

    q)do[3; show i; i:i+1]; show `end
    6
    7
    8
    `end

    if, else are also possible.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.