# Logic

## all¶

Syntax: all x (unary, aggregate)

Returns a boolean atom 1b if all items of x are non-zero, and otherwise 0b.

It applies to all data types except symbol, first converting the type to boolean if necessary.

q)all 1 2 3=1 2 4
q)all 1 2 3=1 2 3
q)if[all x in y;....]   / use in control structure


Note

## not¶

Syntax: not x (unary, atomic)

Returns 0b where x not equal to zero, and 1b otherwise.

Applies to all data types except sym, and to items of lists, dict values and table columns.

q)not -1 0 1 2
0100b
q)not "abc","c"$0 0001b q)not ab!(-1 0 2;"abc","c"$0)
a| 010b
b| 0001b


## null¶

Syntax: null x (unary, atomic)

Returns 1b where x is null.

Applies to all data types except enums, and to items of lists, dict values and table columns.

q)null 0 0n 0w 1 0n
01001b


Enums

Enums always show as non-null.


q)a:a
q)=a$/ non-enumerated and enumerated null symbol show as equivalent 1b q)null/ null symbol behaves as expected 1b q)nulla$/ enumeration of null symbol does not
0b
</code></pre>
The intention was not to have nulls in the enums. That value is used to indicate "out of range". (Think of them as a way to represent foreign keys.) To test for an enumeration backed by a null symbol, one can use the equality test – but at the cost of CPU cycles:
<pre><code class="language-q">
q)a:10000000?8
q)v:a\$a
q)\ts null v
18 16777344
q)\ts=v
66 268435648


## |or (maximum)¶

Syntax: x|y (binary, atomic)
Syntax: x or y (binary, atomic)

Returns the maximum of x and y. It applies to all data types except symbol.

Or numbers

The name or` is used because it behaves as logical OR on boolean arguments, but is extended to maximum on other data types.