Search code examples
kdb

KDB How to cause infinite loop without recursion


Is there an expression that causes an infinite loop in KDB?

This is without using loops or recursion.


Solution

  • A statement including a scan or over adverb can get you stuck in an infinite loop. Something like:

    {sqrt x}\[{x>0};100]
    

    this will continually take the square root of the previous output (with an initial input of 100) until the answer no longer satisfies x>0. So the first argument is effectively a while, even though we don't use the while key word. Is this what you were looking for?