Skip to content

except

Exclude items from a list

x except y    except[x;y]

Where

  • x is a list
  • y is a list or atom

returns all items of x that are not in y (or not equal to y, if y is an atom).

q)1 2 3 except 2
1 3
q)1 2 3 4 1 3 except 2 3
1 4 1
q)"hello" except "l"
"heo"

except uses in to identify items of x in y, which in turn uses Find. It is equivalent to {x where not x in y}.

Where x is a table, the result contains the rows of x that are not in table y.

q)([]a:1 2 3) except ([]a:enlist 2)
a
-
1
3

x must be a list: an atom signals a type error.

q)1 except 2
'type
  [0]  1 except 2
         ^

Find, in, within

Selection