Search code examples
kdbq-lang

How to remove element from list in KDB?


For instance, I have:

x: (`a`b!(1;2); (); `a`b!(3;4))

and I want to remove the (). I have tried using ? (match)

x[x ? not ()]

but that just gives ().

What is the correct expression?

Background

I often use peach to execute a series of queries, and often some will return missing data in the form of (). Hence I want to remove the () and get back to a nice table.


Solution

  • You can use except as well:

    q)x except 1#()
    a b
    ---
    1 2
    3 4