Entries in .Q.s1 (2)

q truncates the results in stdout. How can I fix it?

To set q's console output to 80 columns wide and 24 rows high (console size), use \c:

q)\c 80 24

You can also use the $LINES and $COLUMNS environment variables to have q start up automatically with your preferred settings:

$ export LINES=40
$ export COLUMNS=120
$ q
KDB+ 2.7 2011.02.16 Copyright © 1993-2011 Kx Systems
q)\c
40 120
q)

To adjust the amount of output when access a q server via a web browser, see http page size (\C)

Lastly, you may be interested in .Q.s and .Q.s1

I’m used to sprinkling print statements to debug my code. How can I do the same in q?

Like printf, 0N! is your friend. When you place 0N! before an expression, it prints the result of that expression to the console and then returns it:

q)1 + 0N! til 10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
q)

0N! does change the functionality of your code in one subtle, albeit usually harmless, way. If you place 0N! before a modifier-assignment operator (e.g. +:, -:), then the result of that assignment is no longer null; it is the value assigned:

q){x +: 47} 1
q){0N! x +: 47} 1
48
48
q)

See also: .Q.s and .Q.s1