Skip to content
Jas edited this page Mar 31, 2017 · 5 revisions

Utility Functions

This library contains a set of general utility functions.

.util.inDebugMode

We define the use of the built-in command line argument -e to also define if the process is started in debug mode or not. By using -e 1, this function will return true.

.util.system

Wraps the built-in system command to run it with protected execute. If the system command fails (i.e. the process exits with a non-zero status), this function will throw SystemCallFailedException. The error will also be logged to the console.

.util.trim

An extended version of the built-in trim function. As well as removing spaces from the beginning and end of a string, it also removes new line and tab characters.

.util.isEmpty

A null like function with support for checking empty dictionaries, empty tables and lists will all null elements. Below are some examples of how this function differs to null:

q) null 1 2 3
000b
q) .util.isEmpty 1 2 3
0b
q)null (`;0N;0Np;0Nf)
1111b
q).util.isEmpty (`;0N;0Np;0Nf)
1b
q) null ()!()
q) .util.isEmpty ()!()
1b
q) null flip `col1`col2!"SS"$\:()
col1 col2
---------
q) .util.isEmpty flip `col1`col2!"SS"$\:()
1b

.util.unenumerate

This function will unenumerate any enumerated columns in an unkeyed table.

.util.renameColumn

This function allows you to rename a column, or columns, in a table. The table should be unkeyed prior to passing into this function.

Clone this wiki locally