Overloaded glyphs
Many non-alphabetic keyboard characters are overloaded.
Operator overloads are resolved by rank , and sometimes by the type of argument/s.
@ at
\ backslash
d: data n: non-negative integer atom
u: unary value t: test value
v: value rank>1 x: atom or vector
y, z…: conformable atoms or lists
! bang
a: select specifications
b: group-by specifications
c: where-specifications
h: handle to a splayed or partitioned table
i: integer >0
noasv: symbol atom, the name of a symbol vector
sv: symbol vector
t: table
tk: keyed table
ts: simple table
x,y: same-length lists
: colon
:: colon colon
- dash
Syntax: immediately left of a number, indicates its negative.
q)neg[3]~-3
1b
Otherwise
. dot
In the Debugger , push the stack.
$ dollar
rank
example
semantics
3
$[x>10;y;z]
Cond : conditional evaluation
2
"h"$y, `short$y, 11h$y
Cast : cast datatype
2
"H"$y, -11h$y
Tok : interpret string as data
2
x$y
Enumerate : enumerate y from x
2
10$"abc"
Pad : pad string
2
(1 2 3f;4 5 6f)$(7 8f;9 10f;11 12f)
dot product, matrix multiply, mmu
# hash
? query
' quote
rank
syntax
semantics
1
(u')x, u'[x], x b'y, v'[x;y;…]
Each : iterate u, b or v itemwise
1
'msg
Signal an error
1
int'[x;y;…]
Case : successive items from lists
2
'[u;v]
Compose u with v
u: unary value int: int vector
b: binary value msg: symbol or string
v: value of rank ≥1 x, y: data
': quote-colon
/ slash
rank
syntax
semantics
n/a
/a comment
comment: ignore rest of line
1
(u/)y, u/[y]
Converge
1
n u/ y, u/[n;y]
Do
1
t u/ y, u/[t;y]
While
1
(v/)y, v/[y]
map-reduce : reduce a list or lists
u: unary value t: test value
v: value rank ≥1 y: list
n: non-negative int atom
Syntax: a space followed by / begins a trailing comment . Everything to the right of / is ignored.
q)2+2 / we know this one
4
A / at the beginning of a line marks a comment line . The entire line is ignored.
q)/nothing in this line is evaluated
In a script, a line with a solitary / marks the beginning of a multiline comment . A multiline comment is terminated by a \ or the end of the script.
/
A script to add two numbers.
Version 2018.1.19
\
2+2
/
That's all folks.
_ underscore
rank
example
semantics
2
3_ til 10
Cut , Drop
Names can contain underscores
Best practice is to use a space to separate names and the Cut and Drop operators.
Many of the operators tabulated above have unary forms in k.
Exposed infrastructure