Basic Operations
Mathematical Operations
Add
Subtract
Divide
%
is used instead of /
, as /
is used for comment
Multiply
Order of operation
q follows right to left order instead of BODMAS
Order can be forced using bracketsAssignment
any entity(atom/function/list/table) in q can be assigned to a variable using operator :
q)a:5
q)b:6 / values are not displayed in next line as before, they are stored(assigned)
q)c:7
q)d:a+b+c
q)d / to display value, enter variable name
18
Comparison or Logical operators
Two numbers/entities can be compared using :
<
less than>
greater than<=
less than or equal to>=
greater than or equal to=
equal to - only checks underlying value<>
not equal to~
match - checks underlying value and type
Compound and Multiple Assignment
Compound Assignment
Multiple Assignment
q)a:2
q)c:7*b:2+a / multiple variables are assigned in same statement
q)a
2
q)b
4
q)c
28
q)\v / to view all variables defined till now \v
`a`b`c`x