setdifferencekdbset-difference

KDB: set difference


How can one find set (data structure) difference in KDB? Example:

a: 1 2 3 4
b: 2 3

expected result: 1 4. Simple guesses like a-b or a _ b do not work.

Thank you very much for your help!


Solution

  • You're after the keyword except

    q)a:1 2 3 4;b:2 3
    q)a except b
    1 4