Skip to content

all, any

all

Everything is true

all x    all[x]

Returns a boolean atom 0b; or 1b where x is

  • a list and all items are non-zero
  • a non-zero atom
  • an empty list

Applies to all datatypes except symbols and GUIDs.

Where x is a table, all iterates over its columns and returns a dictionary.

q)all null ([] c1:`a`b`c; c2:0n 0n 0n; c3:10 0N 30)
c1| 0
c2| 1
c3| 0

Strings are cast to boolean.

all is an aggregate function.

q)all 1 2 3=1 2 4
0b
q)all 1 2 3=1 2 3
1b
q)all "YNYN" / string casts to 1111b
1b
q)all () /no zeros here
1b
q)all 2000.01.01
0b
q)all 2000.01.02 2010.01.02
1b

q)if[all x in y;....]   / use in control structure
domain: b g x h i j e f c s p m d z n u v t
range:  b . b b b b b b b . b b b b b b b b

all is a multithreaded primitive.

any

Something is true

any x    any[x]

Returns a boolean atom 0b; or 1b where x is

  • a list with at least one non-zero item
  • a non-zero atom

Applies to all datatypes except symbols and GUIDs. Strings are cast to boolean.

any is an aggregate function.

q)any 1 2 3=10 20 4
0b
q)any 1 2 3=1 20 30
1b
q)any "YNYN" / string casts to 1111b
1b
q)any () / no non-zeros here
0b
q)any 2000.01.01
0b
q)any 2000.01.01 2000.01.02
1b

q)if[any x in y;....]   / use in control structure
domain: b g x h i j e f c s p m d z n u v t
range:  b . b b b b b b b . b b b b b b b b

any is a multithreaded primitive.


Cast, & and, | or, max, min
Logic