# Q language resources by topic


## Casting and encoding


$       [Cast](cast.md) between datatypes
$       [Tok](tok.md): interpret string as value
!       [Enumeration](enumeration.md)
[parse](parse.md)   parse string to function
[string](string.md)  cast to character
[sv](sv.md)      decode to integer
[value](value.md)   parse string to function
[vs](vs.md)      encode


## [Comparison](comparison.md)


[<     Less Than](less-than.md)            [>     Greater Than](greater-than.md)             [deltas  differences](deltas.md)
[<=    Up To](less-than.md)                [>=    At Least](greater-than.md)                 [differ  flag changes](differ.md)
[&     Lesser](lesser.md)               [|     Greater](greater.md)
[min   least, minimum](min.md)       [max   greatest, maximum](max.md)
[mins  running minimums](min.md#mins)     [maxs  running maximums](max.md#maxs)
[mmin  moving minimums](min.md#mmin)      [mmax  moving maximums](max.md#mmax)


[Precision](precision.md)


## [Dictionaries](dictsandtables.md)


[! Dict](dict.md)  make a dictionary         [key](key.md)      key list
[group](group.md)   group list by values      [value](value.md)    value list


## Environment

variable | defines | default
---------|---------|--------
COLUMNS  | [`\c`](syscmds.md#c-console-size) | 80
LINES    | [`\c`](syscmds.md#c-console-size) | 25
QHOME    | folder searched for q.k and unqualified script names | `$HOME/q`  
`C:\q`
QINIT    | additional file loaded after `q.k` has initialized,
executed in the default namespace | `$QHOME/q.q` 
`%QHOME%\q.q`
QLIC     | folder searched for `k4.lic` or `kc.lic` license key file | `$QHOME` 
`%QHOME%`


[getenv](getenv.md)      get value of an environment variable
[gtime](gtime.md)       UTC equivalent of local timestamp
[ltime](gtime.md#ltime)       local equivalent of UTC timestamp
[setenv](getenv.md#setenv)      set value of an environment variable


## [Evaluation control](control.md)


[' ': /: \\:   each peach prior](maps.md "maps")          [\$[test;et;ef;…] Cond](cond.md)
[\\ /          scan over](accumulators.md "accumulators")                 [do](do.md)  [if](if.md)  [while](while.md)

[.[f;x] Apply](apply.md#apply-index)          [.[f;x;e] Trap](apply.md#trap)          [: Return](function-notation.md#explicit-return)        [exit](exit.md)
[@[f;x] Apply-At](apply.md#apply-at-index-at)       [@[f;x;e] Trap-At](apply.md#trap)       [' Signal](signal.md)


## [File system](files.md)


[get set](get.md)       read/write or memory-map a data file¹
[value](value.md)         read a data file¹

[hcount](hcount.md)        file size
[hdel](hdel.md)          delete a file or folder
[hsym](hsym.md)          symbol/s to file symbol/s¹

[0: File Text](file-text.md)      read/write chars¹       [read0](read0.md)  read chars¹
[1: File Binary](file-binary.md)    read/write bytes¹       [read1](read1.md)  read bytes¹
[2: Dynamic Load](dynamic-load.md)   load shared object

[save](save.md#save)   [load](load.md)   a variable
[rsave](save.md#rsave)  [rload](load.md#rload)  a splayed table
[dsave](dsave.md)         tables
[?  Enum Extend](enum-extend.md#filepath)


¹ Has application beyond the file system.


## [Functional qSQL](funsql.md)
```q
![t;c;b;a]              / update and delete

?[t;i;p]                / simple exec

?[t;c;b;a]              / select or exec
?[t;c;b;a;n]            / select up to n records
?[t;c;b;a;n;(g;cn)]     / select up to n records sorted by g on cn
```


## [Interprocess communication](../how_to/io_and_communication/basics.md)


[\p](syscmds.md#p-listening-port)  [-p](cmdline.md#-p-listening-port)          listen to port
[hopen hclose](hopen.md)    open/close connection
[.z](dotz.md)              callbacks


## Joins


**Keyed**                 **As of**
 [ej](ej.md)        equi        [aj aj0](aj.md)      as-of
 [ij ijf](ij.md)    inner       [ajf ajf0](aj.md)
 [lj ljf](lj.md)    left        [asof](asof.md)        simple as-of
 [pj](pj.md)        plus        [wj wj1](wj.md)      window
 [uj ujf](uj.md)    union
 [upsert](upsert.md)                [, Join](join.md)               [^ Coalesce](coalesce.md)


## Logic


[all](all-any.md#all)     whether all items are non-zero
[& and](lesser.md)   lesser of two values; logical AND
[any](all-any.md#any)     whether any item is zero
[not](not.md)     whether if argument is zero
[null](null.md)    whether is null
[| or](greater.md)    greater of two values; logical OR


## [Math and statistics](math.md)


\+ [Add](add.md)      \- [Subtract](subtract.md)   \* [Multiply](multiply.md)    % [Divide](divide.md)
& [Lesser](lesser.md)   | [Greater](greater.md)    $ [dot product, Matrix Multiply](mmu.md)


[abs](abs.md)         absolute value                [mins](min.md#mins)        minimums
[acos](cos.md)        arccosine                     [mmax](max.md#mmax)        moving maximum
[asin](sin.md)        arcsine                       [mmin](min.md#mmin)        moving minimum
[atan](tan.md)        arctangent                    [mmu](mmu.md)         matrix multiply
[avg](avg.md#avg)         arithmetic mean               [mod](mod.md)         modulo
[avgs](avg.md#avgs)        arithmetic means              [msum](sum.md#msum)        moving sum
[ceiling](ceiling.md)     round up to integer           [prd](prd.md)         product
[cor](cor.md)         correlation                   [prds](prd.md#prds)        products
[cos](cos.md)         cosine                        [ratios](ratios.md)      ratios
[cov](cov.md)         covariance                    [reciprocal](reciprocal.md)  reciprocal
[deltas](deltas.md)      differences                   [scov](cov.md#scov)        sample covariance
[dev](dev.md#dev)         standard deviation            [sdev](dev.md#sdev)        sample standard deviation
[div](div.md)         integer division              [signum](signum.md)      sign
[ema](ema.md)         exponential moving average    [sin](sin.md)         sine
[exp](exp.md#exp)         _e_<sup>x</sup>                            [sqrt](sqrt.md)        square root
[floor](floor.md)       round down to integer         [sum](sum.md)         sum
[inv](inv.md)         matrix inverse                [sums](sum.md#sums)        sums
[log](log.md#log)         natural logarithm             [svar](var.md#svar)        sample variance
[lsq](lsq.md)         matrix divide                 [tan](tan.md)         tangent
[mavg](avg.md#mavg)        moving average                [til](til.md)         natural numbers till
[max](max.md#max)         greatest                      [var](var.md#var)         variance
[maxs](max.md#maxs)        maximums                      [wavg](avg.md#wavg)        weighted average
[mcount](count.md#mcount)      moving count                  [wsum](sum.md#wsum)        weighted sum
[mdev](dev.md#mdev)        moving deviation              [xbar](xbar.md)        round down
[med](med.md)         median                        [xexp](exp.md#xexp)        x<sup>y</sup>
[min](min.md#min)         least                         [xlog](log.md#xlog)        base-x logarithm of y


## [QSQL query templates](qsql.md)


[delete](delete.md)  delete rows or columns from a table
[exec](exec.md)    return columns from a table, possibly with new columns
[select](select.md)  return part of a table, possibly with new columns
[update](update.md)  add rows or columns to a table


## Search


[bin, binr](bin.md)    binary search
[distinct](distinct.md)     unique items of a list
[? Find](find.md)       find x in y
[in](in.md)           which items of x are items of y
[within](within.md)       whether x are items of list y


## Selection


[except](except.md)       exclude items of one list or dictionary from another
[first](first.md)         first item of a list or first entry of a dictionary
[. Index](apply.md#index)      select item at depth from a list or entries from a dictionary
[@ Index At](apply.md#index)   select items from a list or entries from a dictionary
[inter](inter.md)        intersection of two lists or dictionaries
[last](first.md#last)         last item of a list or last entry of a dictionary
[next](next.md)         immediately following item/s
[prev](next.md#prev)         immediately preceding item/s
[sublist](sublist.md)      sublist of a list
[union](union.md)        union of two lists or dictionaries
[where](where.md)        copies of indexes of a list, or keys or of a dictionary
[xprev](next.md#xprev)        nearby list items


## Sort


[asc](asc.md)       sort ascending
[desc](desc.md#desc)      sort descending
[group](group.md)     group a list by values
[iasc](asc.md#iasc)      grade ascending
[idesc](desc.md#idesc)     grade descending
[rank](rank.md)      position in sorted list
[xgroup](xgroup.md)    group table by values of selected column/s
[xrank](xrank.md)     assign items to buckets by rank
[xasc](asc.md#xasc)      sort table ascending
[xdesc](desc.md#xdesc)     sort table descending


> **Danger — Duplicate dictionary keys or table column names cause unpredictable results from sorts, grades, and groups.**
>
>
>
> **Warning — Re-sorting compressed data on disk decompresses it.**
>
>
>
[Dictionaries](dictsandtables.md),
[Tables](table.md)


## Strings


[$ Pad](pad.md)   pad with spaces
[like](like.md)    match pattern
[lower](lower.md)   shift to lower case
[ltrim](trim.md)   trim leading space
[md5](md5.md)     hash from string
[rtrim](trim.md)   trim trailing space
[ss](ss.md#ss)      string search
[ssr](ss.md#ssr)     string search and replace
[trim](trim.md)    trim leading and trailing space
[upper](lower.md)   shift to upper case


## [Tables](table.md)


[cols](cols.md)     column names             [ungroup](ungroup.md)  normalize
[meta](meta.md)     metadata                 [xasc](asc.md#xasc)     sort ascending
[xcol](cols.md#xcol)     rename cols              [xdesc](desc.md#xdesc)    sort descending
[xcols](cols.md#xcols)    re-order cols            [xgroup](xgroup.md)   group by values in selected cols
[insert](insert.md)   insert records           [xkey](keys.md#xkey)     sset cols as primary keys
[upsert](upsert.md)   add/insert records       [xdesc](desc.md#xdesc)    sort descending
[! Enkey, Unkey](enkey.md)  add/remove keys

[**qSQL query templates**](qsql.md):   [select](select.md)   [exec](exec.md)   [update](update.md)   [delete](delete.md)
