Search code examples
kdb

KDB: How do I perform a minus on 2 Lists


Input:

a: 1 2 3 4 5 
b: 5 2 6 7

What operation do I need to do to remove all elements of b in a?

Expected Output:

1 3 4

Solution

  • I think the keyword you are looking for is except, like so:

    q)c: a except b
    q)c
        1 3 4
    

    Except returns all elements of its left argument that are absent from the right argument.