How can I find a listing of tables in a given namespace?

To list the tables in the current namespace, use \a; to list the tables from a specific namespace, both \a namespace and tables `namespace work:

$ q sp.q
KDB+ 2.7 2011.02.16 Copyright © 1993-2011 Kx Systems
(+(,`color)!,`blue`green`red)!+(,`qty)!,900 1000 1200
+`s`p`qty!(`s$`s1`s1`s1`s2`s3`s4;`p$`p1`p4`p6`p2`p2`p4;300 200 100 400 200 300)
q)\a .
q)tables `.

What does it mean for a q function or table to be a ‘first class’ type?

Like any other value, you can do the following with functions:

  • pass them as arguments to other functions
  • return them from functions
  • create new functions at run time

In fact, since the syntax of q is consistent with the semantic similarity between calling a function and indexing a data structure, sometimes you won’t even care whether a particular value is a function or data.

Tables can be treated as ordinary data as well. In a typical database, tables can only be manipulated and queried using a special language via a specific access mechanism (.NET’s LINQ is Microsoft’s effort to bridge the gap). In q, although you can use a query language when convenient, you can also use any other feature of the q language that you might want. For example, sometime it’s much simpler or faster to express a table update using . (apply).

Is q a purely functional language?

No. Please see wikipedia entry on Purely functional and programming language family tree diagram (K is found toward the left, as a decendent of APL & Scheme.

This work is licensed under a Creative Commons License.
The views and opinions expressed herein are those of the authors and do not necessarily reflect those of any other person or legal entity.
Kdb+ is the registered trademark of Kx Systems, Inc.