From d1632ba9e6e9326185d7658aa9df7bc30ae0e93c Mon Sep 17 00:00:00 2001 From: Tahir Salkic Date: Mon, 2 Mar 2026 09:15:01 -0500 Subject: [PATCH 1/2] Backported ref changes from kdb-x. Included any missing versions comments. Changed kdb-x to kdb+ --- docs/ref/abs.md | 37 +-- docs/ref/accumulators.md | 24 +- docs/ref/add.md | 31 +- docs/ref/aj.md | 60 ++-- docs/ref/all-any.md | 93 +++--- docs/ref/amend.md | 12 +- docs/ref/apply.md | 30 +- docs/ref/apply_.md | 470 ++++++++++++++++++++++++++++++ docs/ref/asc.md | 239 +++++++-------- docs/ref/asof.md | 96 +++---- docs/ref/assign.md | 18 +- docs/ref/attr.md | 29 +- docs/ref/avg.md | 142 ++++----- docs/ref/bin.md | 30 +- docs/ref/cast.md | 55 ++-- docs/ref/ceiling.md | 27 +- docs/ref/coalesce.md | 10 +- docs/ref/cols.md | 95 +++--- docs/ref/compose.md | 12 +- docs/ref/cond.md | 20 +- docs/ref/cor.md | 70 +++-- docs/ref/cos.md | 32 +-- docs/ref/count.md | 63 ++-- docs/ref/cov.md | 112 ++++---- docs/ref/cross.md | 49 +++- docs/ref/csv.md | 18 +- docs/ref/cut.md | 81 +++--- docs/ref/deal.md | 16 +- docs/ref/delete.md | 20 +- docs/ref/deltas.md | 78 ++--- docs/ref/desc.md | 143 ++++----- docs/ref/dev.md | 103 ++++--- docs/ref/dict.md | 16 +- docs/ref/differ.md | 74 ++--- docs/ref/display.md | 12 +- docs/ref/distinct.md | 29 +- docs/ref/div.md | 79 +++-- docs/ref/divide.md | 32 +-- docs/ref/do.md | 16 +- docs/ref/doth.md | 118 +++----- docs/ref/dotj.md | 19 +- docs/ref/dotm.md | 58 +--- docs/ref/dotq.md | 511 ++++++++++++++++----------------- docs/ref/dotz.md | 422 +++++++++++++-------------- docs/ref/drop.md | 12 +- docs/ref/dsave.md | 84 +----- docs/ref/dynamic-load.md | 18 +- docs/ref/each.md | 55 ++-- docs/ref/ej.md | 20 +- docs/ref/ema.md | 8 +- docs/ref/enkey.md | 16 +- docs/ref/enlist.md | 2 +- docs/ref/enum-extend.md | 22 +- docs/ref/enumerate.md | 16 +- docs/ref/enumeration.md | 18 +- docs/ref/equal.md | 16 +- docs/ref/eval.md | 12 +- docs/ref/except.md | 12 +- docs/ref/exec.md | 30 +- docs/ref/exit.md | 20 +- docs/ref/exp.md | 43 ++- docs/ref/fby.md | 10 +- docs/ref/file-binary.md | 50 ++-- docs/ref/file-text.md | 120 ++++---- docs/ref/fill.md | 8 +- docs/ref/find.md | 10 +- docs/ref/first.md | 10 +- docs/ref/fkeys.md | 10 +- docs/ref/flip-splayed.md | 12 +- docs/ref/flip.md | 4 +- docs/ref/floor.md | 34 +-- docs/ref/get.md | 72 ++--- docs/ref/getenv.md | 10 +- docs/ref/greater-than.md | 23 +- docs/ref/greater.md | 35 +-- docs/ref/group.md | 10 +- docs/ref/gtime.md | 8 +- docs/ref/hcount.md | 22 +- docs/ref/hdel.md | 13 +- docs/ref/hopen.md | 34 +-- docs/ref/hsym.md | 12 +- docs/ref/identity.md | 6 +- docs/ref/if.md | 18 +- docs/ref/ij.md | 16 +- docs/ref/in.md | 16 +- docs/ref/index.md | 150 +++++----- docs/ref/insert.md | 22 +- docs/ref/inter.md | 12 +- docs/ref/inv.md | 12 +- docs/ref/iterators.md | 20 +- docs/ref/join.md | 16 +- docs/ref/key.md | 16 +- docs/ref/keys.md | 16 +- docs/ref/less-than.md | 23 +- docs/ref/lesser.md | 42 +-- docs/ref/like.md | 30 +- docs/ref/lj.md | 18 +- docs/ref/load.md | 44 ++- docs/ref/log.md | 45 ++- docs/ref/lower.md | 15 +- docs/ref/lsq.md | 14 +- docs/ref/maps.md | 56 ++-- docs/ref/match.md | 18 +- docs/ref/max.md | 39 +-- docs/ref/md5.md | 8 +- docs/ref/med.md | 22 +- docs/ref/meta.md | 21 +- docs/ref/min.md | 39 ++- docs/ref/mmu.md | 14 +- docs/ref/mod.md | 30 +- docs/ref/multiply.md | 24 +- docs/ref/neg.md | 20 +- docs/ref/next.md | 12 +- docs/ref/not-equal.md | 16 +- docs/ref/not.md | 18 +- docs/ref/null.md | 6 +- docs/ref/or.md | 10 +- docs/ref/over.md | 16 +- docs/ref/overloads.md | 28 +- docs/ref/pad.md | 22 +- docs/ref/parse.md | 10 +- docs/ref/pj.md | 12 +- docs/ref/prd.md | 23 +- docs/ref/prior.md | 12 +- docs/ref/rand.md | 8 +- docs/ref/rank.md | 10 +- docs/ref/ratios.md | 25 +- docs/ref/raze.md | 6 +- docs/ref/read0.md | 36 ++- docs/ref/read1.md | 35 ++- docs/ref/reciprocal.md | 27 +- docs/ref/reverse.md | 4 +- docs/ref/rotate.md | 6 +- docs/ref/save.md | 71 +++-- docs/ref/select.md | 36 +-- docs/ref/set-attribute.md | 23 +- docs/ref/show.md | 12 +- docs/ref/signal.md | 24 +- docs/ref/signum.md | 29 +- docs/ref/simple-exec.md | 8 +- docs/ref/sin.md | 22 +- docs/ref/sqrt.md | 36 ++- docs/ref/ss.md | 22 +- docs/ref/string.md | 24 +- docs/ref/sublist.md | 10 +- docs/ref/subtract.md | 30 +- docs/ref/sum.md | 51 ++-- docs/ref/sv.md | 12 +- docs/ref/system.md | 40 ++- docs/ref/tables.md | 10 +- docs/ref/take.md | 10 +- docs/ref/tan.md | 24 +- docs/ref/til.md | 10 +- docs/ref/tok.md | 31 +- docs/ref/trim.md | 16 +- docs/ref/type.md | 14 +- docs/ref/uj.md | 20 +- docs/ref/ungroup.md | 10 +- docs/ref/union.md | 10 +- docs/ref/update.md | 32 +-- docs/ref/upsert.md | 18 +- docs/ref/value.md | 8 +- docs/ref/var.md | 18 +- docs/ref/vector-conditional.md | 22 +- docs/ref/view.md | 15 +- docs/ref/vs.md | 14 +- docs/ref/where.md | 12 +- docs/ref/while.md | 16 +- docs/ref/within.md | 12 +- docs/ref/wj.md | 16 +- docs/ref/xbar.md | 31 +- docs/ref/xgroup.md | 12 +- docs/ref/xrank.md | 8 +- 173 files changed, 3280 insertions(+), 3355 deletions(-) create mode 100644 docs/ref/apply_.md diff --git a/docs/ref/abs.md b/docs/ref/abs.md index b89ab8993..90e49c9f9 100644 --- a/docs/ref/abs.md +++ b/docs/ref/abs.md @@ -1,36 +1,38 @@ --- -title: abs – absolute value | Reference | kdb+ and q documentation +title: abs – absolute value | Reference | KDB-X and q documentation description: abs is a q keyword that returns the absolute value of its argument -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `abs` - - - _Absolute value_ ```syntax abs x abs[x] ``` -Where `x` is a numeric or temporal, returns -the absolute value of `x`. -Null is returned if `x` is null. +Where `x` is a numeric, returns +the absolute value of `x`. +`x` is returned if `x` is null. +`abs` also works with temporal values, where it operates on the underlying numeric (refer to the examples below). ```q q)abs -1.0 1f q)abs 10 -43 0N 10 43 0N +q)abs 1999.01.01 +2000.12.31 +// if we convert these to longs, we can observe they're opposite +q)"j"$1999.01.01 2000.12.31 +-365 365 ``` -`abs` is a [multithreaded primitive](../kb/mt-primitives.md). - +`abs` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`abs` is an [atomic function](../basics/atomic.md). +`abs` is an [atomic function](atomic.md). ```q q)abs(10;20 -30) @@ -38,8 +40,7 @@ q)abs(10;20 -30) 20 30 ``` -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). - +It applies to [dictionaries and tables](math.md#dictionaries-and-tables). ## Domain and range @@ -51,8 +52,8 @@ range i . i h i j e f i . p m d z n u v t Range: `ihjefpmdznuvt` ---- -:fontawesome-solid-book: -[`signum`](signum.md) + +[`signum`](signum.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/accumulators.md b/docs/ref/accumulators.md index 08a3c5bdc..c13d71192 100644 --- a/docs/ref/accumulators.md +++ b/docs/ref/accumulators.md @@ -1,8 +1,8 @@ --- -title: Accumulators – Reference – kdb+ and q documentation +title: Accumulators – Reference – KDB-X and q documentation description: An accumulator is an iterator that takes an applicable value as argument and derives a function that evaluates the value, first on its entire (first) argument, then on the results of successive evaluations. -author: Stephen Taylor -keywords: adverb, converge, dictionary, do, iterator, fold, kdb+, keyword, map, map reduce, mnemonic, operator, over, q, scan, unary, value, while +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: adverb, converge, dictionary, do, iterator, fold, KDB-X, keyword, map, map reduce, mnemonic, operator, over, q, scan, unary, value, while --- # Accumulators @@ -32,7 +32,7 @@ t: unary truth map x, y: arguments/indexes of v -An accumulator is an [iterator](iterators.md) that takes an [applicable value](../basics/glossary.md#applicable-value) as argument and derives a function that evaluates the value, first on its entire (first) argument, then on the results of **successive** evaluations. +An accumulator is an [iterator](iterators.md) that takes an [applicable value](glossary.md#applicable-value) as argument and derives a function that evaluates the value, first on its entire (first) argument, then on the results of **successive** evaluations. There are two accumulators, Scan and Over. They have the same syntax and perform the same computation. But where the Scan-derived functions return the result of each evaluation, those of Over return only the last result. @@ -56,7 +56,7 @@ q)(+/)2 3 4 / Over The number of successive evaluations is determined differently for unary and for higher-rank values. -The domain of the accumulators is functions, lists, and dictionaries that represent [finite-state machines](../basics/glossary.md#finite-state-machine). +The domain of the accumulators is functions, lists, and dictionaries that represent [finite-state machines](glossary.md#finite-state-machine). ```q q)yrp / a European tour @@ -85,7 +85,7 @@ Berlin| London x v1\y x v1/y / binary application ``` -The function an accumulator derives from a unary value is [variadic](../basics/variadic.md). +The function an accumulator derives from a unary value is [variadic](variadic.md). The result of the first evaluation is the right argument for the second evaluation. And so on. !!! note "The value is evaluated on the entire right argument, not on items of it." @@ -126,7 +126,7 @@ q)(route\)`Genoa / a circular tour q)(not/) 42 / never returns! ``` -Matching is governed by [comparison tolerance](../basics/precision.md#comparison-tolerance). +Matching is governed by [comparison tolerance](precision.md#comparison-tolerance). ### Do @@ -213,11 +213,11 @@ In the last example, both applicable values are dictionaries. x v\y x v/y ``` -The function an accumulator derived from a binary value is [variadic](../basics/variadic.md). +The function an accumulator derived from a binary value is [variadic](variadic.md). Functions derived by Scan are uniform; functions derived by Over are aggregates. The number of evaluations is the count of the right argument. -![over](../img/over.png) +![over](svg/over.svg)
_Unary and binary application of f/_ @@ -308,7 +308,7 @@ q)m scan c / (m\)c 4 3 1 0 6 9 ``` -:fontawesome-regular-hand-point-right: + [`over`, `scan`](over.md) @@ -455,6 +455,6 @@ q){x+y*z}/[`foo;mt;mt] `foo ``` -:fontawesome-solid-street-view: + _Q for Mortals_ -[§6.7.6 Over (/) for Accumulation](/q4m3/6_Functions/#676-over-for-accumulation) +[§6.7.6 Over (/) for Accumulation](../learn/q4m/6_Functions.md/#676-over-for-accumulation) diff --git a/docs/ref/add.md b/docs/ref/add.md index 05749ae24..da01a1649 100644 --- a/docs/ref/add.md +++ b/docs/ref/add.md @@ -1,16 +1,15 @@ --- -title: Add | Reference | kdb+ and q documentation +title: Add | Reference | KDB-X and q documentation description: A q operator that returns the sum of two numeric, boolean or temporal arguments -keywords: add, kdb+, mathematics, plus, q, sum +keywords: add, KDB-X, mathematics, plus, q, sum --- # `+` Add - ```syntax x+y +[x;y] ``` -Where `x` and `y` are numerics or temporals, returns their +Where `x` and `y` are numerics or temporals, returns their sum. ```q @@ -35,12 +34,11 @@ msoft| 3005 103 Add is generally faster than [Subtract](subtract.md). -`+` is a [multithreaded primitive](../kb/mt-primitives.md). - +`+` is a [multithreaded primitive](mt-primitives.md). ## Implicit iteration -Add is an [atomic function](../basics/atomic.md). +Add is an [atomic function](atomic.md). ```q q)(10;20 30)+(2;3 4) @@ -48,7 +46,7 @@ q)(10;20 30)+(2;3 4) 23 34 ``` -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -77,11 +75,10 @@ def| -42 10 ghi| 6 -12 ``` - ## Range and domains The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt b g x h i j e f c s p m d z n u v t @@ -119,18 +116,16 @@ q)type 1i+55 -7h ``` - ---- -:fontawesome-solid-book: + [Subtract](subtract.md), [`sum`](sum.md), [`.Q.addmonths`](dotq.md#addmonths)
-:fontawesome-solid-book-open: -[Datatypes](../basics/datatypes.md), -[Mathematics](../basics/math.md) + +[Datatypes](datatypes.md), +[Mathematics](math.md)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§4.9.2 Temporal Arithmetic](/q4m3/4_Operators/#492-temporal-arithmetic) +_Q for Mortals_ +[§4.9.2 Temporal Arithmetic](../learn/q4m/4_Operators.md/#492-temporal-arithmetic) diff --git a/docs/ref/aj.md b/docs/ref/aj.md index a9a9c0bc9..d17e91878 100644 --- a/docs/ref/aj.md +++ b/docs/ref/aj.md @@ -1,13 +1,10 @@ --- -title: aj, aj0, ajf, ajf0 – as-of join | Reference | kdb+ and q documentation +title: aj, aj0, ajf, ajf0 – as-of join | Reference | KDB-X and q documentation description: As-of joins join two tables taking from the second the most recent records prior to the times in the first -keywords: as-of, join, kdb+, q +keywords: as-of, join, KDB-X, q --- # `aj`, `aj0`, `ajf`, `ajf0` - - - _As-of join_ ```syntax @@ -17,19 +14,19 @@ ajf [c; t1; t2] ajf0[c; t1; t2] ``` -Where +Where -- `t1` is a table. Since 4.1t 2023.08.04 if `t1` is the name of a table, it is updated in place. -- `t2` is a simple table -- `c` is a symbol list of `n` column names, common to `t1` and `t2`, and of matching type -- column `c[n]` is of a sortable type (typically time) +- `t1` is a table or the name of a table as a symbol (since 4.1t 2023.08.04, in the latter case, the table is updated in place with the result) +- `t2` is a simple table +- `c` is a symbol vector of `n` column names, common to `t1` and `t2`, and of matching type +- column `c``n` is of a sortable type (typically time) returns a table with records from the left-join of `t1` and `t2`. -In the join, columns `c[til n-1]` are matched for equality, and the last value of `c[n]` (most recent time) is taken. +In the join, columns `c``0``...c``n-1` are matched for equality, and the last value of `c``n` (most recent time) is taken. For each record in `t1`, the result has one record with the items in `t1`, and -- if there are matching records in `t2`, the items of the last (in row order) matching record are appended to those of `t1`; -- otherwise the remaining columns are null. +- if there are matching records in `t2`, the items of the last (in row order) matching record are appended to those of `t1`; +- otherwise the remaining columns are null. ```q q)t:([]time:10:01:01 10:01:03 10:01:04;sym:`msft`ibm`ge;qty:100 200 150) @@ -57,11 +54,10 @@ time sym qty px 10:01:04 ge 150 ``` -`aj` is a [multithreaded primitive](../kb/mt-primitives.md). +`aj` is a [multithreaded primitive](mt-primitives.md). !!! tip "There is no requirement for any of the join columns to be keys but the join is faster on keys." - ## `aj`, `aj0` `aj` and `aj0` return different times in their results: @@ -71,10 +67,9 @@ aj boundary time from t1 aj0 actual time from t2 ``` - ## `ajf`, `ajf0` -Since V3.6 2018.05.18 `ajf` and `ajf0` behave as V2.8 `aj` and `aj0`, i.e. they fill from LHS if RHS is null. e.g. +Since V3.6 2018.05.18 `ajf` and `ajf0` behave as V2.8 `aj` and `aj0`; they fill from `t1` if the corresponding value in `t2` is null. For example: ```q q)t0:([]time:2#00:00:01;sym:`a`b;p:1 1;n:`r`s) @@ -84,15 +79,12 @@ q)t0~ajf[`sym`time;t1;t2] 1b ``` - ## Performance !!! warning "Order of search columns" Ensure the first argument to `aj`, the columns to search on, is in the correct order, e.g. `` `sym`time``. Otherwise you’ll suffer a severe performance hit. -If the resulting time value is to be from the quote (actual time) instead of the (boundary time) from trade, use `aj0` instead of `aj`. - `aj` should run at a million or two trade records per second; whether the tables are mapped or not is irrelevant. However, for speed: medium | t2\[c1\] | t2\[c2…\] | example @@ -100,16 +92,15 @@ medium | t2\[c1\] | t2\[c2…\] | example memory | `g#` | sorted within c1 | `quote` has `` `g#sym`` and `time` sorted within `sym` disk | `p#` | sorted within c1 | `quote` has `` `p#sym`` and `time` sorted within `sym` -Departure from this incurs a severe performance penalty. - -Note that, on disk, the `g#` attribute does not help. +Departure from this incurs a severe performance penalty. -!!! warning "Select the virtual partition column only if you need it. It is fabricated on demand, which can be slow for large partitions." +Note that on disk, the `g#` attribute does not help. +!!! warning "Select the virtual partition column only if you need it. It is constructed on demand, which can be slow for large partitions." ## `select` from `t2` -In memory, there is no need to select from `t2`. Irrespective of the number of records, use, e.g.: +In memory, there is no need to select from `t2`. Irrespective of the number of records, use, for example: ```q aj[`sym`time;select … from trade where …;quote] @@ -122,9 +113,9 @@ aj[`sym`time;select … from trade where …; select … from quote where …] ``` -In contrast, on disk you must map in your splay or day-at-a-time partitioned database: +In contrast, on disk, you must map your splayed or partitioned database to memory first: -Splay: +Splayed: ```q aj[`sym`time;select … from trade where …;select … from quote] @@ -139,17 +130,16 @@ aj[`sym`time;select … from trade where …; !!! warning "If further `where` constraints are used, the columns will be _copied_ instead of mapped into memory, slowing down the join." -If you are using a database where an individual day’s data is spread over multiple partitions the on-disk `p#` will be lost when retrieving data with a constraint such as `…date=2011.08.05`. +If you are using a database where an individual day’s data is spread over multiple partitions the on-disk `p#` will be lost when retrieving data with a constraint such as `…date=2011.08.05`. In this case you will have to reduce the number of quotes retrieved by applying further constraints – or by re-applying the attribute. - ---- -:fontawesome-solid-book: -[`asof`](asof.md) + +[`asof`](asof.md)
-:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.9.8 As-of Joins](/q4m3/9_Queries_q-sql/#998-as-of-joins) +[§9.9.8 As-of Joins](../learn/q4m/9_Queries_q-sql.md/#998-as-of-joins) diff --git a/docs/ref/all-any.md b/docs/ref/all-any.md index 419a8f9af..69d1aaae2 100644 --- a/docs/ref/all-any.md +++ b/docs/ref/all-any.md @@ -1,47 +1,35 @@ --- -title: all, any – Reference – kdb+ and q documentation +title: all, any – Reference – KDB-X and q documentation description: all and any are q keywords that invoke aggregator functions for vectors of flags -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `all`, `any` - - - ## `all` -_Everything is true_ - +_Is every item true?_ ```syntax all x all[x] ``` -Returns a boolean atom `0b`; or `1b` where `x` is +Returns a boolean atom `1b` if `x` is -- a list and all items are non-zero -- a non-zero atom -- an empty list +- a list and all items are nonzero (this includes the empty list) +- a nonzero atom; -Applies to all datatypes except symbols and GUIDs. - -Where `x` is a table, `all` iterates over its columns and returns a dictionary. +returns `0b` otherwise. -```q -q)all null ([] c1:`a`b`c; c2:0n 0n 0n; c3:10 0N 30) -c1| 0 -c2| 1 -c3| 0 -``` +Applies to all datatypes except symbols and GUIDs. -Strings are [cast](cast.md) to boolean. +Strings are [cast](cast.md) to boolean; the only character that casts to zero is the [null character](https://en.wikipedia.org/wiki/Null_character "Wikipedia"), represented in q by the escape sequence `"\000"`. Note that this is _not_ the same as the character atom considered null by q, which is `" "`. -`all` is an aggregate function. +Where `x` is a table, `all` iterates over its columns and returns a dictionary. ```q -q)all 1 2 3=1 2 4 +q)all 1 2 3 = 1 2 4 0b -q)all 1 2 3=1 2 3 +q)all 1 2 3 = 1 2 3 1b q)all "YNYN" / string casts to 1111b 1b @@ -51,66 +39,81 @@ q)all 2000.01.01 0b q)all 2000.01.02 2010.01.02 1b - -q)if[all x in y;....] / use in control structure +q)all " \000" +0b +q)all null " \000" +0b +q)all ([] c1:1 2 3; c2:0n 0w -0w; c3:0 1 2f) +c1| 1 +c2| 1 +c3| 0 ``` +`all` is an aggregate function. + ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: b . b b b b b b b . b b b b b b b b ``` -`all` is a [multithreaded primitive](../kb/mt-primitives.md). +`all` is a [multithreaded primitive](mt-primitives.md). ## `any` -_Something is true_ +_Is there a true item?_ ```syntax any x any[x] ``` -Returns a boolean atom `0b`; or `1b` where `x` is +Returns a boolean atom `1b` if `x` is -- a list with at least one non-zero item -- a non-zero atom +- a list with at least one nonzero item, +- a nonzero atom; -Applies to all datatypes except symbols and GUIDs. -Strings are [cast](cast.md) to boolean. +returns `0b` otherwise. -`any` is an aggregate function. +All other notes are the same as for `all` above. ```q -q)any 1 2 3=10 20 4 +q)any 1 2 3 = 10 20 4 0b -q)any 1 2 3=1 20 30 +q)any 1 2 3 = 1 20 30 1b q)any "YNYN" / string casts to 1111b 1b -q)any () / no non-zeros here +q)any () / no nonzeros here 0b +q)any " \000" +1b +q)any null " \000" +1b q)any 2000.01.01 0b q)any 2000.01.01 2000.01.02 1b - -q)if[any x in y;....] / use in control structure +q)any ([] c1:1 2 3; c2:0n 0w -0w; c3:000b) +c1| 1 +c2| 1 +c3| 0 ``` + +`any` is an aggregate function. + ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: b . b b b b b b b . b b b b b b b b ``` -`any` is a [multithreaded primitive](../kb/mt-primitives.md). +`any` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book: [Cast](cast.md), [`&` `and`](lesser.md), [`|` `or`](greater.md), [`max`](max.md), [`min`](min.md)
-:fontawesome-solid-book-open: -[Logic](../basics/by-topic.md#logic) + +[Logic](by-topic.md#logic) diff --git a/docs/ref/amend.md b/docs/ref/amend.md index 7f8fd7894..3439f2e71 100644 --- a/docs/ref/amend.md +++ b/docs/ref/amend.md @@ -1,7 +1,7 @@ --- -title: Amend, Amend At – Reference – kdb+ and q documentation +title: Amend, Amend At – Reference – KDB-X and q documentation description: Operators Amend and Amend At modify one or more items in a list. -keywords: amend, amend at, at, dot, kdb+, q +keywords: amend, amend at, at, dot, KDB-X, q --- # `.` `@` Amend, Amend At @@ -45,7 +45,7 @@ and if `d` is a See also binary and ternary forms of `.` and `@`
-:fontawesome-solid-book: + [Apply, Apply At, Index, Index At](apply.md) @@ -307,12 +307,12 @@ type/attr error amending file test ``` ---- -:fontawesome-solid-book: + [Apply, Apply At, Index, Index At](apply.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§6.8.3 General Form of Function Application](/q4m3/6_Functions/#683-general-form-of-function-application) +[§6.8.3 General Form of Amend At and Amend](../learn/q4m/6_Functions.md#683-general-form-of-amend-at-and-amend) + + +### Nulls in `i` + +Nulls in `i` mean “select all”: if `i[0]` is null, then continue on with `d` and the rest of `i`, i.e. `1_i`; if `i[1]` is null, then for every selection made through `i[0]`, continue on with that selection and the rest of `i`, i.e. `2_i`; and so on. For example, `d .(::;0)` means that the 0th item of every item of `d` is selected. + +```q +q)d +(1 2 3;4 5 6 7) +(8 9;10;11 12) +(13 14;15 16 17 18;19 20) +q)d . (::;0) +1 2 3 +8 9 +13 14 +``` + +Another example, this time with `i[1]` equal to null: + +```q +q)d . (0 2;::;1 0) +(2 1;5 4) +(14 13;16 15;20 19) +``` + +Note that `d .(::;0)` is the same as `d .(0 1 2;0)`, but in the last example, there is no value that can be substituted for null in `(0 2;;1 0)` to get the same result, because when item 0 of `d` is selected, null acts like `0 1`, but when item 2 of `d` is selected, it acts like `0 1 2`. + + +### The general case of a non-negative integer list `i` + +In the general case, when the items of `i` are non-negative integer atoms or lists, or null, the structure of the result can be thought of as cascading structures of the items of `i`. That is, with nulls aside, the result is structurally like `i[0]`, except that wherever there is an atom in `i[0]`, the result is structurally like `i[1]`, except that wherever there is an atom in `i[1]`, the result is structurally like `i[2]`, and so on. + +The general case of Index can be defined recursively in terms of [**Index At**](#index-at) by partitioning the list `i` into its first item and the rest: + +```q +Index:{[d;F;R] + $[ F~::; Index[d; first R; 1 _ R]; + 0 =count R; d @ F; + 0>type F; Index[d @ F; first R; 1 _ R] + Index[d;; R]'F ]} +``` + +That is, `d . i` is `Index[d;first i;1_i]`. + +To work through the definition, start with `F` as the first item of `i` and `R` as the remainder. At each step in the recursion: + +- if `F` is null then select all of `d` and continue on, with the first item of the remainder `R` as the new `F` and the remainder of `R` as the new remainder; +- otherwise, if the remainder is the empty vector apply Index At (the right argument `F` is now the last item of `i`), and we are done; +- otherwise, if `F` is an atom, apply Index At to select that item of `d` and continue on in the same way as when `F` is null; +- otherwise, apply Index with fixed arguments `d` and `R`, but independently to the items of the list `F`. + + +### Dictionaries and symbolic indexing + +If `i` is a symbol atom then `d` must be a dictionary or handle of a directory on the K-tree, and `d . i` selects the value of the entry named in `i`. For example, if: + +```q +dir:`a`b!(2 3 4;"abcdefg") +``` + +then `` `dir . enlist`b`` is `"abcdefg"` and `` `dir . (`b;1 3 5)`` is `"bdf"`. + +If `i` is a list whose items are non-negative integer atoms and symbol atoms, then just like the non-negative integer vector case, `d . i` is a single item at depth `count i` in `d`. The difference is that wherever a symbol appears in `i`, say as the kth item, the selection up to the kth item must produce a dictionary or a handle of a directory. Selection by the kth item is the value of an entry in that dictionary or directory, and further selections go on from there. For example: + +```q +q)(1;`a`b!(2 3 4;10 20 30 40)) . (1; `b; 2) +30 +``` + +As we have seen above for the general case, every atom in the `k`th item of `i` must be a valid index of all items at depth `k` selected by `d . k # i`. Moreover, symbols can only select from dictionaries and directories, and integers cannot. +Consequently, if the `k`th item of `i` contains a symbol atom, then all items selected by `d . k # i` must be dictionaries or handles of directories, and therefore all atoms in the `k`th item of `i` must be symbols. + +It follows that each item of `i` must be made up entirely of non-negative integer atoms, or entirely of symbol atoms, and if the `k`th item of `i` is made up of symbols, then all items at depth `k` in `d` selected by the first `k` items of `i` must be dictionaries. + +Note that if `d` is either a dictionary or handle to a directory then `d . enlist key d` is a list of values of all the entries. + + +### Step dictionaries + +Where `d` is a dictionary, `d@i` or `d[i]` or `d i` returns for each item of `i` that is _outside_ the domain of `d` a null of the same type as the keys. + +```q +q)d:`cat`cow`dog`sheep!`chat`vache`chien`mouton +q)d +cat | chat +cow | vache +dog | chien +sheep| mouton +q)d `sheep`snake`cat`ant +`mouton``chat` +q) +q)e:(10*til 10)!til 10 +q)e +0 | 0 +10| 1 +20| 2 +30| 3 +40| 4 +50| 5 +60| 6 +70| 7 +80| 8 +90| 9 +q)e 80 35 20 -10 +8 0N 2 0N +``` + +A _step dictionary_ has the _sorted_ attribute set. +Its keys are a sorted vector. +Where `s` is a step dictionary, and `i[k]` are the items of `i` that are _outside_ the domain of `d`, the value/s for `d@i@k` are the values for the highest keys that are lower than `i k`. + +```q +q)d:`cat`cow`dog`sheep!`chat`vache`chien`mouton +q)ds:`s#d +q)ds~d +1b +q)ds `sheep`snake`cat`ant +`mouton`mouton`chat` +q) +q)es:`s#e +q)es~e +1b +q)es 80 35 20 -10 +8 3 2 0N +``` + +:fontawesome-solid-book: +[Set Attribute](set-attribute.md) +
+:fontawesome-solid-globe: +[Step Dictionaries](https://cillianreilly.com/blog/step-dictionary.q) + + +## Apply At, Index At + +`@` is [syntactic sugar](https://en.wikipedia.org/wiki/Syntactic_sugar "Wikipedia") for the case where `u` is a unary and `ux` a 1-item list. +`u@ux` is always equivalent to `u . enlist ux`. + +!!! note "Brackets are syntactic sugar" + + The brackets of an argument list are also syntactic sugar. Nothing can be expressed with brackets that cannot also be expressed using `.`. + +You can use the derived function `@\:` to apply a list of unary values to the same argument. + +```q +q){`o`h`l`c!(first;max;min;last)@\:x}1 2 3 4 22 / open, high, low, close +o| 1 +h| 22 +l| 1 +c| 22 +``` + + +## Composition + +A sequence of unaries `u`, `v`, `w`… can be composed with Apply At as `u@v@w@`. +All but the last `@` may be elided: `u v w@`. + +```q +q)tc:til count@ / indexes of a list +q)tc "abc" +"0 1 2" +``` + +The last value in the sequence can have higher rank if projected as a unary by Apply. + +```q +q)di:reciprocal(%). / divide into +q)di 2 3 / divide 2 into 3 +1.5 +``` + +:fontawesome-solid-book: +[Compose](compose.md) + +## Trap + +In the ternary, if evaluation of the function fails, the expression is evaluated. +(Compare try/catch in some other languages.) + +```q +q).[+;"ab";`ouch] +`ouch +``` + +If the expression is a function, it is evaluated on the text of the signalled error. + +```q +q).[+;"ab";{"Wrong ",x}] +"Wrong type" +``` + +For a successful evaluation, the ternary returns the same result as the binary. + +```q +q).[+;2 3;{"Wrong ",x}] +5 +``` + + +### Trap At + +`@[f;fx;e]` is equivalent to `.[f;enlist fx;e]`. + +Use Trap At as a simpler form of Trap, for unary values. + +:fontawesome-solid-book: +[.Q.trp](dotq.md#trp-extend-trap-at) (extend trap at) + + +### Limit of the trap + +Trap catches only errors signalled in the applications of `f` or `g`. Errors in the evaluation of `fx` or `gg` themselves are not caught. + +```q +q)@[2+;"42";`err] +`err +q)@[2+;"42"+3;`err] +'type + [0] @[2+;"42"+3;`err] + ^ +``` + + +### When `e` is not a function + +If `e` is a function it will be evaluated _only_ if `f` or `g` fails. It will however be _parsed_ before any of the other expressions are evaluated. + +```q +q)@[2+;"42";{)}] +') + [0] @[2+;"42";{)}] + ^ +``` + +If `e` is any _other_ kind of expression it will _always_ be evaluated – and _first_, in the usual right-to-left sequence. In this respect Trap and Trap At are unlike try/catch in other languages. + +```q +q)@[string;42;a:100] / expression not a function +"42" +q)a // but a was assigned anyway +100 +q)@[string;42;{b::99}] / expression is a function +"42" +q)b // not evaluated +'b + [0] b + ^ +``` + +For most purposes, you will want `e` to be a function. + +:fontawesome-solid-street-view: +_Q for Mortals_ +[§10.1.8 Protected Evaluation](/q4m3/10_Execution_Control/#1018-protected-evaluation) + + +## Errors signalled + +```txt +index an atom in vx or ux is not an index to an item-at-depth in d +rank the count of vx is greater than the rank of v +type v or u is a symbol atom, but not a handle to an value +type an atom of vx or ux is not an integer, symbol or null +``` + + +---- +:fontawesome-solid-book: +[Amend, Amend At](amend.md) diff --git a/docs/ref/asc.md b/docs/ref/asc.md index 4baaa0caa..afb01b1d9 100644 --- a/docs/ref/asc.md +++ b/docs/ref/asc.md @@ -1,18 +1,12 @@ --- -title: asc, iasc, xasc – ascending sort | Reference | kdb+ and q documentation +title: asc, iasc, xasc – ascending sort | Reference | KDB-X and q documentation description: Ascending sorts in q; asc returns a sortable argument in ascending order; iasc grades its items into ascending order; xasc sorts a table by columns. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `asc`, `iasc`, `xasc` - _Sort and grade: ascending_ - - - -!!! info "Q chooses from a variety of algorithms, depending on the type and data distribution." - ## `asc` _Ascending sort_ @@ -21,18 +15,21 @@ _Ascending sort_ asc x asc[x] ``` -Where `x` is a: +Where `x` is a + +- **vector**, returns its items in ascending order of value, with the [sorted attribute](set-attribute.md) set, indicating the list is sorted. +- **mixed list**, returns the items sorted within datatype and with the sorted attribute set; +- **nested list**, returns the items sorted lexicographically and with the sorted attribute set; +- **dictionary**, returns it sorted by the values; +- **table**, returns it sorted lexicographically by the non-key columns, and + - if there is only one non-key column, setting the sorted attribute set on that column, + - otherwise, setting the parted attribute on the first non-key column. -- **vector**, returns its items in ascending order of value, with the [sorted attribute](set-attribute.md) set, indicating the list is sorted; where the argument vector is found to be in ascending order already, it is assigned the sorted attribute -- **mixed list**, returns the items sorted within datatype and with the sorted attribute set -- **dictionary**, returns it sorted by the values -- **table**, returns it sorted by the first non-key column and with - + the sorted attribute set on that column if there is only one non-key column; otherwise - + the parted attribute set +!!! info "Q chooses from a variety of sorting algorithms depending on the datatype and data distribution." -The function is uniform. -The sort is stable: it preserves order between equals. +The sort is stable: it preserves order between equals. If the list was already sorted, this means that the only thing that happens is the attribute being set, and therefore that also happens **in place** (``s` is the only attribute that behaves this way). +`asc` is a uniform function. ### Vector @@ -42,9 +39,9 @@ q)asc 2 1 3 4 2 1 2 q)a:0 1 q)b:a -q)asc b / result has sorted attribute +q)asc b / result has sorted attribute applied `s#0 1 -q)b / argument was already in ascending order +q)b / argument was already in ascending order, so the application happened in place `s#0 1 q)a / b was a shallow copy of a `s#0 1 @@ -55,31 +52,35 @@ q)a / b was a shallow copy of a In the example below, the boolean is returned first, then the sorted integers, the sorted characters, and then the date. ```q -q)asc (1;1b;"b";2009.01.01;"a";0) +q)show l:asc (1;1b;"b";2009.01.01;"a";0) 1b 0 1 "a" "b" 2009.01.01 + +q)type each l +-1 -7 -7 -10 -10 -14h / datatypes are sorted by their type number ``` -Note how the type numbers are used. +!!! warning + + Because of this functionality, it is essential to ensure that a list has matching datatypes if we want to sort it (unless we want exactly this to happen). + +### Nested list ```q -q)asc(2f;3;4i;5h) -5h -4i -3 -2f -q){(asc;x iasc abs t)fby t:type each x}(2f;3;4i;5h) / compare asc -5h -4i -3 -2f +q)l:("bat";"dog";"cow";"cat") +q)asc l +"bat" +"cat" +"cow" +"dog" +q)attr asc l / the result has the sorted attribute, but the console doesn't show that with nested lists +`s ``` - ### Dictionary ```q @@ -89,35 +90,34 @@ a| 2 c| 3 ``` - ### Table ```q q)/ simple table -q)asc ([]a:3 4 1;b:`a`d`s) +q)asc ([]a:4 3 4;b:`s`a`d) a b --- -1 s 3 a 4 d -q)meta asc ([]a:3 4 1;b:`a`d`s) / sets parted attribute +4 s +q)meta asc ([]a:3 4 1;b:`a`d`s) / sets parted attribute c| t f a -| ----- a| j p b| s -q)meta asc([]a:3 4 1) / sets sorted attribute +q)meta asc([]a:3 4 1) / sets sorted attribute c| t f a -| ----- a| j s q)/ keyed table -q)meta asc ([c1:`a`b] c2:2 1; c3:01b) / sets parted attribute +q)meta asc ([c1:`a`b] c2:2 1; c3:01b) / sets parted attribute c | t f a --| ----- c1| s c2| j p c3| b -q)meta asc ([c1:`a`b] c2:2 1) / sets sorted attribute +q)meta asc ([c1:`a`b] c2:2 1) / sets sorted attribute c | t f a --| ----- c1| s @@ -126,8 +126,8 @@ c2| j s ``` ```txt -domain: b g x h i j e f c s p m d z n u v t -range: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T +range: B G X H I J E F C S P M D Z N U V T ``` ## `iasc` @@ -138,7 +138,7 @@ _Ascending grade_ iasc x iasc[x] ``` -Where `x` is a list or dictionary, returns the indexes needed to sort list `x` in ascending order. +Where `x` is a list or dictionary, returns the indices needed to sort the list `x` in ascending order. ```q q)L:2 1 3 4 2 1 2 @@ -148,32 +148,31 @@ q)L iasc L 1 1 2 2 2 3 4 q)(asc L)~L iasc L 1b -q)iasc `a`c`b!1 2 3 -`a`c`b +q)iasc `a`b`c!2 3 1 +`c`a`b ``` -Reverse a sort with `iasc iasc`: +!!! tip + You can invert an ordering with `iasc`: -```q -q)x:100?100 -q)b:100?.Q.a -q)c:b iasc x -q)b~c iasc iasc x -1b -``` + ```q + q)show is:0N?til 5 + 4 2 1 3 0 + q)b:`a`b`c`d`e + q)b is + `e`b`c`d`a + q)b[is] iasc is + `a`b`c`d`e + ``` ```txt -domain: b g x h i j e f c s p m d z n u v t -range: j j j j j j j j j j j j j j j j j j +domain: B G X H I J E F C S P M D Z N U V T +range: J J J J J J J J J J J J J J J J J J ``` ## `xasc` - -_Sort a table in ascending order of specified columns._ - -![xasc](../img/xasc.png) -{: style="float: right; margin: 0 0 0 1em; padding: 0;"} +_Sort a table in ascending order of specified columns._ ```syntax x xasc y xasc[x;y] @@ -181,74 +180,57 @@ x xasc y xasc[x;y] Where `x` is a symbol vector of column names defined in table `y`, which is passed by -- value, returns -- reference, updates +- value, returns +- [reference](glossary.md#reference-pass-by), updates -`y` sorted in ascending order by `x`. +`y` sorted in ascending order by `x`. The sort is by the first column specified, then by the second column within the first, and so on. The sorted attribute is set on the first column given (if possible). The sort is stable, i.e. it preserves order amongst equals. ```q -q)\l sp.q -q)s -s | name status city ---| ------------------- -s1| smith 20 london -s2| jones 10 paris -s3| blake 30 paris -s4| clark 20 london -s5| adams 30 athens -q)`city xasc s / sort on city -s | name status city ---| ------------------- -s5| adams 30 athens -s1| smith 20 london -s4| clark 20 london -s2| jones 10 paris -s3| blake 30 paris -q)`city`name xasc s / sort on city, and name within city -s | name status city ---| ------------------- -s5| adams 30 athens -s4| clark 20 london -s1| smith 20 london -s3| blake 30 paris -s2| jones 10 paris -q)`status`city`name xasc s / sort on 3 columns, status first -s | name status city ---| ------------------- -s2| jones 10 paris -s4| clark 20 london -s1| smith 20 london -s5| adams 30 athens -s3| blake 30 paris -q)`status`city`name xasc `s / table given by reference, updated in place -`s -q)s -s | name status city ---| ------------------- -s2| jones 10 paris -s4| clark 20 london -s1| smith 20 london -s5| adams 30 athens -s3| blake 30 paris -q)meta s / status column has sorted attribute -c | t f a -------| ----- -s | s -name | s -status| i s -city | s +q)show t:0N?([]sym:raze 2#/:`a`b`c; date:6#2025.01.01+til 2; val:50+6?10f) +sym date val +----------------------- +c 2025.01.01 51.95847 +a 2025.01.02 53.40721 +b 2025.01.01 50.54001 +b 2025.01.02 55.49794 +a 2025.01.01 53.83946 +c 2025.01.02 55.61526 +q)`date xasc t +sym date val +----------------------- +c 2025.01.01 51.95847 +b 2025.01.01 50.54001 +a 2025.01.01 53.83946 +a 2025.01.02 53.40721 +b 2025.01.02 55.49794 +c 2025.01.02 55.61526 +q)`sym`date xasc t +sym date val +----------------------- +a 2025.01.01 53.83946 +a 2025.01.02 53.40721 +b 2025.01.01 50.54001 +b 2025.01.02 55.49794 +c 2025.01.01 51.95847 +c 2025.01.02 55.61526 +q)`sym`date xasc `t +`t +q)meta t / sym column has sorted attribute +c | t f a +----| ----- +sym | s s +date| d +val | f ``` +**Duplicate column names** +`xasc` signals `'dup` and the duplicate column name if it finds duplicate columns in the right argument. (Since V3.6 2019.02.19.) -**Duplicate column names** `xasc` signals `dup` if it finds duplicate columns in the right argument. (Since V3.6 2019.02.19.) - -:fontawesome-regular-hand-point-right: -[`.Q.id` (sanitize)](dotq.md#id-sanitize) - +[`.Q.id` (sanitize)](dotq.md#id-sanitize) ### Sorting data on disk @@ -284,21 +266,18 @@ s 30 0 a 43 2 ``` - !!! warning "Duplicate keys in a dictionary or duplicate column names in a table cause sorts and grades to return unpredictable results." - ---- -:fontawesome-solid-book: -[`attr`](attr.md), -[`desc`, `idesc`, `xdesc`](desc.md), -[Set Attribute](set-attribute.md) -
-:fontawesome-solid-book-open: -[Dictionaries & tables](../basics/dictsandtables.md), -[Metadata](../basics/metadata.md), -[Sorting](../basics/by-topic.md#sort) + +[`attr`](attr.md); +[`desc`, `idesc`, `xdesc`](desc.md); +[Set Attribute](set-attribute.md) + +[Dictionaries & tables](dictsandtables.md), +[Metadata](metadata.md), +[Sorting](by-topic.md#sort)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§8.8 Attributes](/q4m3/8_Tables#88-attributes) \ No newline at end of file +[§8.9 Attributes](../learn/q4m/8_Tables.md#89-attributes) diff --git a/docs/ref/asof.md b/docs/ref/asof.md index 259aca432..907e81887 100644 --- a/docs/ref/asof.md +++ b/docs/ref/asof.md @@ -1,84 +1,58 @@ --- -title: asof – Reference – kdb+ and q documentation +title: asof – Reference – KDB-X and q documentation description: Where t1 is a table and t2 is a table or dictionary in which the last key or column of t2 corresponds to a time column in t1, asof[t1;t2] returns the values from the last rows matching the rest of the keys and time ≤ the time in t2. -keywords: asof, join, kdb+, q +keywords: asof, join, KDB-X, q --- # `asof` - - - _As-of join_ ```syntax -t1 asof t2 asof[t1;t2] +t asof d asof[t;d] ``` Where -- `t1` is a table -- `t2` is a table or dictionary -- the last key or column of `t2` corresponds to a time column in `t1` +- `t` is a table +- `d` is a dictionary (or table) with `n` keys (or columns) that correspond to columns in `t` +- the last key (or column) of `d` corresponds to a sortable column in `t` (usually time) -returns the values from the last rows matching the rest of the keys and time ≤ the time in `t2`. +returns the values of the remaining columns from the last row in `t` for which -```q -q)show trade asof`sym`time!(`IBM;09:30:00.0) -price| 96.3e -size | 200 -stop | 0b -corr | 0 -cond | "T" -ex | "D" +- the first `n-1` values each match the first `n-1` values of `d`, and +- the last value is not greater than the last value of `d`. -q)show trade asof([]sym:`AAPL`IBM;ex:"TD";time:09:30:00.0) -price size stop corr cond -------------------------- -78.14 100 0 0 T -96.3 200 0 0 T -``` - -The following examples use the `mas` table from TAQ. +If no items match the criteria, either because there are no rows that match in the first `n-1` columns, or because the last value is smaller than the last value in the first such row, a dictionary of nulls is returned. ```q -q)`date xasc`mas / sort by date -`mas - -q)show a!mas asof a:([]sym:`A`B`C`GOOG;date:1995.01.01) -sym date | cusip name wi ex uot ----------------| -------------------------------------------------- -A 1995.01.01| 049870207 ATTWOODS PLC ADS REP5 ORD/5PNC 0 N 100 -B 1995.01.01| 067806109 BARNES GROUP INCORPORATED 0 N 100 -C 1995.01.01| 171196108 CHRYSLER CORP 0 N 100 -GOOG 1995.01.01| 0 - -q)show a!mas asof a:([]sym:`A`B`C`GOOG;date:2006.01.01) -sym date | cusip name wi ex uot ----------------| --------------------------------------------- -A 2006.01.01| 00846U101 AGILENT TECHNOLOGIES, INC 0 N 100 -B 2006.01.01| 067806109 BARNES GROUP INCORPORATED 0 N 100 -C 2006.01.01| 172967101 CITIGROUP 0 N 100 -GOOG 2006.01.01| 38259P508 GOOGLE INC CLASS A 0 T 100 - -q)show a!mas asof a:([]sym:`A;date:1993.01.05 1996.05.23 2000.08.04) -sym date | cusip name wi ex uot ---------------| -------------------------------------------------- -A 1993.01.05| 049870207 ATTWOODS PLC ADS REP5 ORD/5PNC 0 N 100 -A 1996.05.23| 046298105 ASTRA AB CL-A ADS 1CL-ASEK2.50 0 N 100 -A 2000.08.04| 00846U101 AGILENT TECHNOLOGIES INC 0 N 100 +q)show t:([] time:6#09:00+10*til 3; sym:raze flip 3 2#`AAPL`GOOG; px:6?100f; vol:6?100) +time sym px vol +----------------------- +09:00 AAPL 81.77547 36 +09:10 AAPL 75.20102 12 +09:20 AAPL 10.86824 97 +09:00 GOOG 95.98964 92 +09:10 GOOG 3.668341 99 +09:20 GOOG 64.30982 45 +q)t asof `sym`time!(`AAPL;09:15) +px | 75.20102 +vol| 12 +q)t asof ([]sym:`GOOG`MSFT; time:09:05) +px vol +------------ +95.98964 92 + / a row of nulls for no match ``` -`asof` is a [multithreaded primitive](../kb/mt-primitives.md). +`asof` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book: -[`aj`](aj.md), -[`wj`](wj.md) -
-:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[`aj`](aj.md), +[`wj`](wj.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§9.9.8 As-of Joins](/q4m3/9_Queries_q-sql/#998-as-of-joins) +_Q for Mortals_ +[§9.9.8 As-of Joins](../learn/q4m/9_Queries_q-sql.md/#998-as-of-joins) diff --git a/docs/ref/assign.md b/docs/ref/assign.md index 141455739..b938e3e26 100644 --- a/docs/ref/assign.md +++ b/docs/ref/assign.md @@ -1,7 +1,7 @@ --- -title: Assign operator | Reference | kdb+ and q documentation +title: Assign operator | Reference | KDB-X and q documentation description: Name a value in q -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # Assign @@ -135,7 +135,7 @@ q)s [Amend At](amend.md) is more general, and extends assignment-through-operator to derived functions, keywords and lambdas. -If `x` is undefined, the [identity element](../basics/glossary.md#identity-element) for `op` is used as a default. +If `x` is undefined, the [identity element](glossary.md#identity-element) for `op` is used as a default. ```q q)bar @@ -144,14 +144,14 @@ q)bar ^ q)bar+:1 q)bar -1 +1q4m ``` Some operators have significant differences between their base and assignment form, for example [`,`](join.md). ## Pattern match -See [Pattern matching](../basics/pattern.md#assignment) +See [Pattern matching](pattern.md#assignment) ## Syntax @@ -198,10 +198,10 @@ q):/[1 2 3 4 5] ``` ---- -:fontawesome-solid-book: -[Amend, Amend At](../ref/amend.md) + +[Amend, Amend At](amend.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.6.2 Simple q Amend](/q4m3/4_Operators/#462-simple-q-amend) +[§4.6.2 Simple q Amend](../learn/q4m/4_Operators.md/#462-simple-q-amend) diff --git a/docs/ref/attr.md b/docs/ref/attr.md index adc252711..44854be77 100644 --- a/docs/ref/attr.md +++ b/docs/ref/attr.md @@ -1,29 +1,26 @@ --- -title: attr – attributes of an object | Reference | kdb+ and q documentation +title: attr – attributes of an object | Reference | KDB-X and q documentation description: attr is a q keyword that returns the attributes of an object -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `attr` - - - -_Attributes of an object_ +_Attribute of an object_ ```syntax attr x attr[x] ``` -Where `x` is any object, returns its attributes as a symbol vector. +Where `x` is any object, returns its attribute as a symbol atom. The possible attributes are: code | attribute :---:|--------------------- -s | sorted -u | unique (hash table) -p | partitioned (grouped) -g | true index (dynamic attribute): enables constant time update and access for real-time tables +```s`` | sorted +```u`` | unique +```p`` | parted +```g`` | grouped A null symbol result `` ` `` means no attributes are set on `x`. @@ -32,18 +29,16 @@ q)attr 1 3 4 ` q)attr asc 1 3 4 `s -q)attr ({x+y}) -` ``` +For more information on each of the attributes, please refer to the documentation pages in the footer. ---- -:fontawesome-solid-book: [Set Attribute](set-attribute.md)
-:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) + +[Metadata](metadata.md)
_Q for Mortals_ -[§8.8 Attributes](/q4m3/8_Tables/#88-attributes) +[§8.9 Attributes](../learn/q4m/8_Tables.md#89-attributes) diff --git a/docs/ref/avg.md b/docs/ref/avg.md index 10d0a35bc..c2f069c3c 100644 --- a/docs/ref/avg.md +++ b/docs/ref/avg.md @@ -1,15 +1,12 @@ --- -title: avg, avgs, mavg, wavg – average, running average, moving averages, weighted average | Reference | kdb+ and q documentation +title: avg, avgs, mavg, wavg – average, running average, moving averages, weighted average | Reference | KDB-X and q documentation description: avg and wavg are q keywords invoking aggregate functions for the arithmetic and weighted means of a vector. avgs and mavgs are q keywords that invoke uniform functions that return the cumulative and moving means of a vector -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `avg`, `avgs`, `mavg`, `wavg` - _Averages_ - - ## `avg` _Arithmetic mean_ @@ -22,38 +19,42 @@ Where `x` is a numeric or temporal list, returns the arithmetic mean as a float. The mean of an atom is its value as a float. -Null is returned if `x` is empty, or contains both positive and negative infinity. Where `x` is a vector null items are ignored. +Null is returned if `x` is empty, or contains both positive and negative infinity. + +- If `x` is a vector, null items are ignored. +- If `x` is a mixed list, null items are treated as zero. +- If `x` is a nested list, null items make the average null. ```q q)avg 1 2 3 2f -q)avg 1 0n 2 3 / vector: null items are ignored -2f -q)avg (1 2;0N 4) / nested: null items are preserved -0n 3 -q)avg 1.0 0w +q)avg 1 0w 0w q)avg -0w 0w 0n +q)avg 1 0n 2 3 / note: this is a float vector! +2f +q)avg (1;0n;2;3) +1.5 +q)avg (1 2;0N 4) +0n 3 q)avg 101b 0.6666667 q)avg 1b 1f -q)\l trade.q -q)show select ap:avg price by sym from trade -sym| ap ----| ----- -a | 10.75 +q)avg ([]a:3 5; b:6 8f) +a| 4 +b| 7 ``` `avg` is an aggregate function, equivalent to `{sum[x]%count x}`. ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: f . f f f f f f f . f f f f f f f f ``` -`avg` is a [multithreaded primitive](../kb/mt-primitives.md). +`avg` is a [multithreaded primitive](mt-primitives.md). ## `avgs` @@ -74,8 +75,8 @@ q)avgs 1 2 3 0n 4 -0w 0w `avgs` is a uniform function, equivalent to `(avg\)`. ```txt -domain: b g x h i j e f c s p m d z n u v t -range: f . f f f f f f . . f f f f f f f f +domain: B G X H I J E F C S P M D Z N U V T +range: F . F F F F F F . . F F F F F F F F ``` ## `mavg` @@ -88,33 +89,35 @@ x mavg y mavg[x;y] Where -- `x` is a positive int atom (not infinite) -- `y` is a numeric list +- `x` is a positive int atom (not infinite) +- `y` is a numeric list -returns the `x`-item [simple moving averages](https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average) of `y`, with any nulls after the first item replaced by zero. The first `x` items of the result are the averages of the terms so far, and thereafter the result is the moving average. The result is floating point. +returns the `x`-item [simple moving averages](https://en.wikipedia.org/wiki/Moving_average#Simple_moving_average) of `y`, with any nulls replaced by zero. The first `x` items of the result are the averages of the terms so far, and thereafter the result is the moving average. The result is of type float. If the first item of `y` is null, the first item of the result will also be null (instead of zero). ```q q)2 mavg 1 2 3 5 7 10 1 1.5 2.5 4 6 8.5 q)5 mavg 1 2 3 5 7 10 1 1.5 2 2.75 3.6 5.4 -q)5 mavg 0N 2 0N 5 7 0N / nulls after the first are replaced by 0 +q)5 mavg 0N 2 0N 5 7 0N / first item of the result is null 0n 2 2 3.5 4.666667 4.666667 q)0 mavg 2 3 0n 0n ``` `mavg` is a uniform function. + Domain and range: + ```txt - b g x h i j e f c s p m d z n u v t + B G X H I J E F C S P M D Z N U V T ---------------------------------------- -b | f . f f f f f f . . f f f f f f f f +b | F . F F F F F F . . F F F F F F F F g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f . . f f f f f f f f -h | f . f f f f f f . . f f f f f f f f -i | f . f f f f f f . . f f f f f f f f -j | f . f f f f f f . . f f f f f f f f +x | F . F F F F F F . . F F F F F F F F +h | F . F F F F F F . . F F F F F F F F +i | F . F F F F F F . . F F F F F F F F +j | F . F F F F F F . . F F F F F F F F e | . . . . . . . . . . . . . . . . . . f | . . . . . . . . . . . . . . . . . . c | . . . . . . . . . . . . . . . . . . @@ -128,8 +131,8 @@ u | . . . . . . . . . . . . . . . . . . v | . . . . . . . . . . . . . . . . . . t | . . . . . . . . . . . . . . . . . . ``` -Range: `f` +Range: `F` ## `wavg` @@ -141,15 +144,15 @@ x wavg y wavg[x;y] Where -- `x` is a numeric list -- `y` is a numeric list +- `x` is a numeric list +- `y` is a numeric list -returns the average of numeric list `y` weighted by numeric list `x`. The result is a float atom. +returns the average of numeric list `y` weighted by numeric list `x`. The result is a float atom. ```q q)2 3 4 wavg 1 2 4 2.666667 -q)2 0N 4 5 wavg 1 2 0N 8 / nulls in either argument ignored +q)2 0N 4 5 wavg 1 2 0N 8 / nulls in either argument are ignored 6f q)0 wavg 2 3 0n / since 4.1t 2021.09.03,4.0 2021.10.01, previously returned 2.5 @@ -157,11 +160,11 @@ q)0 wavg (1 2;3 4) 0n 0n / since 4.0/4.1 2024.07.08, previously returned 0n ``` -Where `x` and `y` conform, the result has an atom for each sublist. +IF `x` and `y` are conforming nested lists, the result has an atom for each sublist. ```q q)(1 2;3 4) wavg (500 400; 300 200) -350 266.6667 +350 266.6667 / note: this is (1 3 wavg 500 300; 2 4 wavg 400 200) ``` The financial analytic known as VWAP (volume-weighted average price) is a weighted average. @@ -175,48 +178,49 @@ a | 10.75 `wavg` is an aggregate function, equivalent to `{(sum x*y)%sum x}`. Domain and range: + ```txt - b g x h i j e f c s p m d z n u v t + B G X H I J E F C S P M D Z N U V T ---------------------------------------- -b | f . f f f f f f f . f f f f f f f f -g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f f . f f f f f f f f -h | f . f f f f f f f . f f f f f f f f -i | f . f f f f f f f . f f f f f f f f -j | f . f f f f f f f . f f f f f f f f -e | f . f f f f f f f . f f f f f f f f -f | f . f f f f f f f . f f f f f f f f -c | f . f f f f f f f . f f f f f f f f -s | . . . . . . . . . . . . . . . . . . -p | f . f f f f f f f . f f f f f f f f -m | f . f f f f f f f . f f f f f f f f -d | f . f f f f f f f . f f f f f f f f -z | f . f f f f f f f . f f f f f f f f -n | f . f f f f f f f . f f f f f f f f -u | f . f f f f f f f . f f f f f f f f -v | f . f f f f f f f . f f f f f f f f -t | f . f f f f f f f . f f f f f f f f +B | f . f f f f f f f . f f f f f f f f +G | . . . . . . . . . . . . . . . . . . +X | f . f f f f f f f . f f f f f f f f +H | f . f f f f f f f . f f f f f f f f +I | f . f f f f f f f . f f f f f f f f +J | f . f f f f f f f . f f f f f f f f +E | f . f f f f f f f . f f f f f f f f +F | f . f f f f f f f . f f f f f f f f +C | f . f f f f f f f . f f f f f f f f +S | . . . . . . . . . . . . . . . . . . +P | f . f f f f f f f . f f f f f f f f +M | f . f f f f f f f . f f f f f f f f +D | f . f f f f f f f . f f f f f f f f +Z | f . f f f f f f f . f f f f f f f f +N | f . f f f f f f f . f f f f f f f f +U | f . f f f f f f f . f f f f f f f f +V | f . f f f f f f f . f f f f f f f f +T | f . f f f f f f f . f f f f f f f f + ``` Range: `f` -`wavg` is a [multithreaded primitive](../kb/mt-primitives.md). - +`wavg` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`avg`, `avgs`, and `mavg` apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). -`wavg` applies to dictionaries. +`avg`, `avgs`, and `mavg` apply to [dictionaries and tables](math.md#dictionaries-and-tables). +`wavg` applies to dictionaries. ```q -q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) +q)kt:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) q)avg d 7 13 4.5 q)avg t a| 11.33333 b| 5 -q)avg k +q)avg kt a| 11.33333 b| 5 @@ -238,15 +242,11 @@ q)1 2 wavg d 6 10.33333 5 ``` - ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) -
-:fontawesome-brands-wikipedia-w: -[Weighted average mean](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean "Wikipedia") + +[Mathematics](math.md)
-:fontawesome-brands-wikipedia-w: -[Volume-weighted average price (VWAP)](https://en.wikipedia.org/wiki/Volume-weighted_average_price "Wikipedia") +[Weighted average mean](https://en.wikipedia.org/wiki/Weighted_arithmetic_mean "Wikipedia") +[Volume-weighted average price (VWAP)](https://en.wikipedia.org/wiki/Volume-weighted_average_price "Wikipedia") diff --git a/docs/ref/bin.md b/docs/ref/bin.md index 55e1bf322..d12df703a 100644 --- a/docs/ref/bin.md +++ b/docs/ref/bin.md @@ -1,14 +1,10 @@ --- -title: bin, binr | Reference | kdb+ and q documentation +title: bin, binr | Reference | KDB-X and q documentation description: bin and binr are q keywords that perform binary searches. -keywords: bin, binr, kdb+, q, search_ +keywords: bin, binr, KDB-X, q, search, Find --- # `bin`, `binr` - - - - _Binary search_ ```syntax @@ -20,10 +16,10 @@ x binr y binr[x;y] Where -- `x` is a sorted list -- `y` is an atom of exactly the same type (no type promotion) +- `x` is a sorted list +- `y` is an atom of exactly the same type (no type promotion) -returns the index of the _last_ item in `x` which is ≤`y`. The result is `-1` for `y` less than the first item of `x`. If `x` is a simple list, `bin` is [atomic](../basics/atomic.md) in `y`. (For higher ranks of either argument, `bin` works the same way as [`?` (Find)](find.md/#type-specific).) +returns the index of the _last_ item in `x` which is ≤`y`. The result is `-1` for `y` less than the first item of `x`. If `x` is a simple list, `bin` is [atomic](atomic.md) in `y`. (For higher ranks of either argument, `bin` works the same way as [`?` (Find)](find.md/#type-specific).) `binr` _binary search right_, introduced in V3.0 2012.07.26, gives the index of the _first_ item in `x` which is ≥`y`. ```q @@ -62,7 +58,7 @@ The result `r` can be interpreted as follows: for an atom `y`, `r` is an integer ```txt r[i]=-1 iff y[i] -:fontawesome-solid-book-open: -[Search](../basics/by-topic.md#search) +[Search](by-topic.md#search) diff --git a/docs/ref/cast.md b/docs/ref/cast.md index 6d04447ae..e0d12f181 100644 --- a/docs/ref/cast.md +++ b/docs/ref/cast.md @@ -1,12 +1,10 @@ --- -title: Cast converts data to another datatype | Reference | kdb+ and q documentation +title: Cast converts data to another datatype | Reference | KDB-X and q documentation description: Cast is a q operator that converts a data argument to another datatype. --- # `$` Cast - - _Convert to another datatype_ ```syntax @@ -15,7 +13,7 @@ x$y $[x;y] Where `x` is: -- a **positive short, lower-case letter, or symbol** from the following table, returns `y` cast according to `x` +- a **positive short, lower-case letter, or symbol** from the following table, returns `y` cast according to `x` ```txt 1h "b" `boolean @@ -37,19 +35,19 @@ Where `x` is: 19h "t" `time ``` -- a symbol from the list **`` `year`dd`mm`hh`uu`ss``** and `y` is a temporal type, returns the year, day, month, hour, minute, or seconds value from `y` as [tabulated below](#temporal) +- a symbol from the list **`` `year`dd`mm`hh`uu`ss``** and `y` is a temporal type, returns the year, day, month, hour, minute, or seconds value from `y` as [tabulated below](#temporal) -- **`0h` or `"*"`**, and `y` is not a string, returns `y` ([Identity](#identity)) +- **`0h` or `"*"`**, and `y` is not a string, returns `y` ([Identity](#identity)) -- an **upper-case letter** or a **negative short int** interprets the value from a string, see [Tok](tok.md) +- an **upper-case letter** or a **negative short int** interprets the value from a string, see [Tok](tok.md) Casting does not change the underlying bit pattern of the data, only how it is represented. -`$`(cast) is a [multithreaded primitive](../kb/mt-primitives.md). +`$`(cast) is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Iteration +## Iteration -Cast is an [atomic function](../basics/atomic.md). +Cast is an [atomic function](atomic.md). ```q q)12 13 14 15 16 17 18 19h$42 @@ -77,7 +75,6 @@ q)(12h;13 14h)$(42;42 42) (2003.07m;2000.02.12) ``` - ## Integer Cast to integer: @@ -92,7 +89,6 @@ q)`int$(neg\)6.1 6.6 -6 -7 ``` - ## Boolean Cast to boolean: @@ -112,7 +108,6 @@ q)"b"$" ",.Q.an 1111111111111111111111111111111111111111111111111111111111111111b ``` - ## Byte ```q @@ -133,19 +128,18 @@ q)"x"$"abc" This is considered an error and is planned to change to `0x00`. - ## Temporal -The following symbols can be used to extract parts of a temporal type +Use the following symbols to extract parts of a temporal type: -* `year` to provide year as an integer -* `month` to provide `month` datatype -* `mm` to provide month as an integer, where January is 01i -* `week` to provide a `date` datatype, presenting the week in which the temporal variable resides. The value returned is the start of the week (Monday). If the `date` represents a Monday, it is not altered. -* `dd` to provide day as an integer, where 1st of the month is 1i -* `hh` to provide hour as an integer -* `uu` to provide minutes as an integer -* `ss` to provide to seconds as an integer +- `year` to provide year as an integer +- `month` to provide `month` datatype +- `mm` to provide month as an integer, where January is `01i` +- `week` to provide a `date` datatype, presenting the week in which the temporal variable resides. The value returned is the start of the week (Monday). If the `date` represents a Monday, it is not altered. +- `dd` to provide day as an integer, where 1st of the month is `1i` +- `hh` to provide hour as an integer +- `uu` to provide minutes as an integer +- `ss` to provide seconds as an integer For example: @@ -155,8 +149,7 @@ q)`hh`uu`ss$03:55:58.11 q)`year`dd`mm`hh`uu`ss$2015.10.28D03:55:58 2015 28 10 3 55 58i ``` - -The following shows which information can be extracted from each temporal [datatype](../basics/datatypes.md) +The following shows which information can be extracted from each temporal [datatype](datatypes.md). ```txt | year | month | mm | week | dd | hh | uu | ss @@ -169,6 +162,7 @@ timespan | | | | | | x | x | x minute | | | | | | x | x | x second | | | | | | x | x | x time | | | | | | x | x | x + ``` !!! detail "Casting to narrower temporal type truncates rather than rounds" @@ -179,7 +173,7 @@ time | | | | | | x | x | x As a consequence `.z.t-.z.n` is typically negative. -Numeric calculations on the base numeric type can also be used to extract part of a temporal type, for the example using the [`mod`](mod.md) keyword +Numeric calculations on the base numeric type can also be used to extract part of a temporal type, for the example using the [`mod`](mod.md) keyword: ```q milliseconds: "i"$01:00:00.100 mod 1000 / extract milliseconds from time datatype @@ -212,13 +206,12 @@ q)`float$0Wh !!! tip "The infinity corresponding to numeric `x` is `min 0#x`." ---- -:fontawesome-solid-book: + [Tok](tok.md)
-:fontawesome-solid-book: + [Overloads of `$`](overloads.md#dollar)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§7.2 Cast](/q4m3/7_Transforming_Data/#731-data-to-strings) +_Q for Mortals_ +[§7.2 Cast](../learn/q4m/7_Transforming_Data.md/#731-data-to-strings) diff --git a/docs/ref/ceiling.md b/docs/ref/ceiling.md index c4bd0815e..1843feb5e 100644 --- a/docs/ref/ceiling.md +++ b/docs/ref/ceiling.md @@ -1,17 +1,16 @@ --- -title: ceiling | Reference | kdb+ and q documentation +title: ceiling | Reference | KDB-X and q documentation description: ceiling is a q keyword that returns the least integer greater than its numeric argument. --- # `ceiling` - _Round up_ ```syntax ceiling x ceiling[x] ``` -Returns the least integer greater than or equal to boolean or numeric `x`. +Returns the least integer greater than or equal to boolean or numeric `x`. ```q q)ceiling -2.1 0 2.1 @@ -20,11 +19,11 @@ q)ceiling 01b 0 1i ``` -`ceiling` is a [multithreaded primitive](../kb/mt-primitives.md). +`ceiling` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`ceiling` is an [atomic function](../basics/atomic.md). +`ceiling` is an [atomic function](atomic.md). ```q q)ceiling(1.2;3.4 5.6) @@ -42,12 +41,11 @@ a b 4 8 ``` - -## :fontawesome-solid-triangle-exclamation: Prior to V3.0 +## Prior to V3.0 Prior to V3.0, `ceiling` -- used [comparison tolerance](../basics/precision.md#comparison-tolerance) +- used [comparison tolerance](precision.md#comparison-tolerance) - accepted datetime (Since V3.0, use `"d"$23:59:59.999+` instead.) ```q @@ -60,19 +58,18 @@ q)"d"$23:59:59.999+ 2010.05.13T12:30:59.999 2010.05.14 ``` - ## Domain and range ```txt domain b g x h i j e f c s p m d z n u v t range i . i h i j j j i . . . . . . . . . ``` -Range: `hij` +Range: `hij` ---- -:fontawesome-solid-book: -[`floor`](floor.md) + +[`floor`](floor.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/coalesce.md b/docs/ref/coalesce.md index ce1985cd6..05829b2a5 100644 --- a/docs/ref/coalesce.md +++ b/docs/ref/coalesce.md @@ -1,7 +1,7 @@ --- -title: Coalesce operator | Reference | kdb+ and q documentation +title: Coalesce operator | Reference | KDB-X and q documentation description: Coalesce is a q operator that merges keyed tables. -keywords: coalesce, join, kdb+,q +keywords: coalesce, join, KDB-X,q --- # `^` Coalesce @@ -35,7 +35,7 @@ q)(kt1^kt2) ~ kt1,kt2 1b ``` -:fontawesome-solid-book: + [`^` Fill](fill.md) where `x` and `y` are lists or dictionaries When `y` has null column values, the column values of `x` are updated only with non-null values of `y`. @@ -66,6 +66,6 @@ k| c1 c2 The performance of Coalesce is slower than that of Join since each column value of `y` must be checked for null. ---- -:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md) diff --git a/docs/ref/cols.md b/docs/ref/cols.md index 41dd958e2..ccb58f123 100644 --- a/docs/ref/cols.md +++ b/docs/ref/cols.md @@ -1,15 +1,12 @@ --- -title: cols, xcol, xcols | Reference | kdb+ and q documentation +title: cols, xcol, xcols | Reference | KDB-X and q documentation description: cols, xcol and xcols are q keywords. cols returns the column names of a table. xcol renames tablecolumns. xcols reorders table columns. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `cols`, `xcol`, `xcols` - _Table columns_ - - ## `cols` _Column names of a table_ @@ -18,13 +15,13 @@ _Column names of a table_ cols x cols[x] ``` -Where `x` is a +Where `x` is a -- table -- the name of a table as a symbol atom -- a filesymbol for a splayed table +- table +- the name of a table as a symbol atom +- a filesymbol for a splayed table -returns as a symbol vector its column names. +returns its column names as a symbol vector. ```q q)\l trade.q @@ -34,7 +31,6 @@ q)cols`trade /reference `time`sym`price`size ``` - ## `xcol` _Rename table columns_ @@ -43,31 +39,32 @@ _Rename table columns_ x xcol y xcol[x;y] ``` -Where `y` is a table, passed by value, and `x` is +Where `y` is a table passed by value, and `x` is -- a **symbol vector** of length no greater than `count cols y` returns `y` with its first `count x` columns renamed -- a **dictionary** (since V3.6 2018.08.24) formed from two symbol vectors, of which the keys are all the names of columns of `y`, returns `y` with columns renamed according to the dictionary +- a **symbol vector** of length no greater than `count cols y` returns `y` with its first `count x` columns renamed +- a **dictionary** (since V3.6 2018.08.24) formed from two symbol vectors, returns `y` with the columns in `key x` renamed as `value x` ```q -q)\l trade.q -q)cols trade -`time`sym`price`size -q)`Time`Symbol xcol trade / rename first two columns -Time Symbol price size ------------------------------- -09:30:00.000 a 10.75 100 -q)trade:`Time`Symbol`Price`Size xcol trade / rename all and assign -q)cols trade -`Time`Symbol`Price`Size -q)(`a`c!`A`C)xcol([]a:();b:();c:()) / rename selected columns +q)t:([]a:3 4 5; b:6 7 8; c:`z`u`i) +q)`d`e xcol t / rename first two columns +d e c +----- +3 6 z +4 7 u +5 8 i +q)([a:`A;c:`C]) xcol t / rename selected columns A b C ----- +3 6 z +4 7 u +5 8 i +q)([q:`r]) xcol t / nonexistent column names in key x signal a length error +'length + [0] ([q:`r]) xcol t ``` -:fontawesome-solid-street-view: _Q for Mortals_ -[§9.8.1 `xcol`](/q4m3/9_Queries_q-sql/#981-xcol) - +[§9.8.1 `xcol`](../learn/q4m/9_Queries_q-sql.md/#981-xcol) ## `xcols` @@ -77,37 +74,33 @@ _Reorder table columns_ x xcols y xcols[x;y] ``` -Where +Where -- `y` is a simple table, passed by value -- `x` is a symbol vector of some or all of `y`’s column names +- `y` is a simple table passed by value +- `x` is a symbol vector of some or all of `y`’s column names (can also be an atom) returns `y` with `x` as its first column/s. ```q -q)\l trade.q -q)cols trade -`time`sym`price`size -q)trade:xcols[reverse cols trade;trade] / reverse cols and reassign trade -q)cols trade -`size`price`sym`time -q)cols trade:`sym xcols trade / move sym to the front -`sym`size`price`time +q)t:([]a:3 4 5; b:6 7 8; c:`z`u`i) +q)`b xcols t +b a c +----- +6 3 z +7 4 u +8 5 i +q)t:xcols[reverse cols t;t] / reverse cols and reassign +q)cols t +`c`b`a ``` -:fontawesome-solid-street-view: _Q for Mortals_ -[§9.8.2 `xcols`](/q4m3/9_Queries_q-sql/#982-xcols) - +[§9.8.2 `xcols`](../learn/q4m/9_Queries_q-sql.md/#982-xcols) ---- -:fontawesome-solid-book: -[`meta`](meta.md), -[`.Q.V`](dotq.md#v-table-to-dict) (table to dictionary) -
-:fontawesome-solid-book-open: -[Dictionaries](../basics/dictsandtables.md), -[Metadata](../basics/metadata.md) + +[Dictionaries](dictsandtables.md), +[Metadata](metadata.md)
-:fontawesome-solid-graduation-cap: -[Tables](../kb/faq.md) \ No newline at end of file + +[Tables](faq.md) diff --git a/docs/ref/compose.md b/docs/ref/compose.md index c73249e84..2af4a7dd2 100644 --- a/docs/ref/compose.md +++ b/docs/ref/compose.md @@ -1,8 +1,8 @@ --- -title: Compose – compose functions together | Reference | kdb+ and q documentation +title: Compose – compose functions together | Reference | KDB-X and q documentation description: Compose is a q operator that composes (or curries) a unary value with another. The rank of the result is the rank of the second argument. -author: Stephen Taylor -keywords: adverb, compose, composition, function, kdb+, map, q, value +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: adverb, compose, composition, function, KDB-X, map, q, value --- # `'` Compose @@ -17,7 +17,7 @@ _Compose a unary value with another_ Where -- `f` is a unary [value](../basics/glossary.md#applicable-value) +- `f` is a unary [value](glossary.md#applicable-value) - `ff` is a value rank ≥1 the derived function `'[f;ff]` has the rank of `ff` and returns `f ff[x;y;z;…]`. @@ -73,5 +73,5 @@ If we take `-100` to flag parts of `x`, the expression `max 0 (0|+)\x` returns t ---- -:fontawesome-solid-graduation-cap: -[Q Phrasebook](https://code.kx.com/phrases/) \ No newline at end of file + +[Q Phrasebook](phrases/index.md) \ No newline at end of file diff --git a/docs/ref/cond.md b/docs/ref/cond.md index 8177c07f5..d19f1211d 100644 --- a/docs/ref/cond.md +++ b/docs/ref/cond.md @@ -1,8 +1,8 @@ --- -title: Cond | Reference | kdb+ and q documentation +title: Cond | Reference | KDB-X and q documentation description: Cond is a q control construct for conditional evaluation. -author: Stephen Taylor -keywords: cond, conditional, control, dollar, kdb+, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: cond, conditional, control, dollar, KDB-X, q --- # `$` Cond @@ -104,23 +104,23 @@ Name scope within its brackets is the same as outside them. Using [`if`](if.md) is a clearer signal to the reader that a side effect is intended.) - Also, setting a variable in a code branch can have [unintended consequences](../basics/function-notation.md#name-scope). + Also, setting a variable in a code branch can have [unintended consequences](function-notation.md#name-scope). ## Query templates -Cond is not supported inside [qSQL queries](../basics/qsql.md). +Cond is not supported inside [qSQL queries](qsql.md). Instead, use [Vector Conditional](vector-conditional.md). ---- -:fontawesome-solid-book: + [`$` dollar](overloads.md#dollar), [Vector Conditional](vector-conditional.md)
-:fontawesome-solid-book-open: -[Controlling evaluation](../basics/control.md) + +[Controlling evaluation](control.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§10.1.1 Basic Conditional Evaluation](/q4m3/10_Execution_Control/#1011-basic-conditional-evaluation) +[§10.1.1 Basic Conditional Evaluation](../learn/q4m/10_Execution_Control.md/#1011-basic-conditional-evaluation) diff --git a/docs/ref/cor.md b/docs/ref/cor.md index 66eb57330..94ac201a9 100644 --- a/docs/ref/cor.md +++ b/docs/ref/cor.md @@ -1,30 +1,33 @@ --- -title: cor – corelation coefficient | Reference | kdb+ and q documentation +title: cor – correlation coefficient | Reference | KDB-X and q documentation description: cor is a q keyword that calculates the correlation coefficient of two numeric lists. +tags: correlation --- # `cor` - - _Correlation_ ```syntax x cor y cor[x;y] ``` -Where `x` an d `y` are [conforming](../basics/conformable.md) numeric lists returns their correlation as a float in the range `-1f` to `1f`. - -Perfectly correlated data results in a `1` or `-1`. When one variable increases as the other increases the correlation is positive; when one decreases as the other increases it is negative. - -Completely uncorrelated arguments return `0f`. +Where `x` and `y` are [conforming](conformable.md) numeric lists, returns their (Pearson) [correlation](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient) as a float in the range `-1f` to `1f`. Nulls (along with their pairs) are ignored. ```q q)29 10 54 cor 1 3 9 0.7727746 q)10 29 54 cor 1 3 9 0.9795734 +q)1 3 9 cor 1 3 9 +1f q)1 3 9 cor neg 1 3 9 -1f +q)1 3 1 3 cor 1 1 3 3 +0f +q)1 1 1 cor 1 3 9 +0n +q)1 3 0N cor 1 3 9 /nulls are ignored +1f q)1000101000b cor 0010011001b -0.08908708 @@ -32,44 +35,35 @@ q)1000101000b cor 0010011001b `cor` is an aggregate function, equivalent to `{cov[x;y]%dev[x]*dev y}`. -`cor` is a [multithreaded primitive](../kb/mt-primitives.md). - +`cor` is a [multithreaded primitive](mt-primitives.md). ## Domain and range ```txt - b g x h i j e f c s p m d z n u v t + B G X H I J E F C S P M D Z N U V T ---------------------------------------- -b | f . f f f f f f f . f f f f f f f f -g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f f . f f f f f f f f -h | f . f f f f f f f . f f f f f f f f -i | f . f f f f f f f . f f f f f f f f -j | f . f f f f f f f . f f f f f f f f -e | f . f f f f f f f . f f f f f f f f -f | f . f f f f f f f . f f f f f f f f -c | f . f f f f f f f . f f f f f f f f -s | . . . . . . . . . . . . . . . . . . -p | f . f f f f f f f . f f f f f f f f -m | f . f f f f f f f . f f f f f f f f -d | f . f f f f f f f . f f f f f f f f -z | f . f f f f f f f . f f f f f f f f -n | f . f f f f f f f . f f f f f f f f -u | f . f f f f f f f . f f f f f f f f -v | f . f f f f f f f . f f f f f f f f -t | f . f f f f f f f . f f f f f f f f +B | f . f f f f f f f . f f f f f f f f +G | . . . . . . . . . . . . . . . . . . +X | f . f f f f f f f . f f f f f f f f +H | f . f f f f f f f . f f f f f f f f +I | f . f f f f f f f . f f f f f f f f +J | f . f f f f f f f . f f f f f f f f +E | f . f f f f f f f . f f f f f f f f +F | f . f f f f f f f . f f f f f f f f +C | f . f f f f f f f . f f f f f f f f +S | . . . . . . . . . . . . . . . . . . +P | f . f f f f f f f . f f f f f f f f +M | f . f f f f f f f . f f f f f f f f +D | f . f f f f f f f . f f f f f f f f +Z | f . f f f f f f f . f f f f f f f f +N | f . f f f f f f f . f f f f f f f f +U | f . f f f f f f f . f f f f f f f f +V | f . f f f f f f f . f f f f f f f f +T | f . f f f f f f f . f f f f f f f f ``` Range: `f` - ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) -
-:fontawesome-brands-wikipedia-w: -[Correlation and dependence](https://en.wikipedia.org/wiki/Correlation_and_dependence "Wikipedia") -
-:fontawesome-solid-globe: -[Correlation](http://financereference.com/learn/correlation "financereference.com") +[Mathematics](math.md) diff --git a/docs/ref/cos.md b/docs/ref/cos.md index cd280a862..9ff7d65e1 100644 --- a/docs/ref/cos.md +++ b/docs/ref/cos.md @@ -1,27 +1,22 @@ --- -title: cos, acos – cosine and arccosine | Reference | kdb+ and q documentation +title: cos, acos – cosine and arccosine | Reference | KDB-X and q documentation description: cos and acos are q keywords. They return the cosine and arccosine respectively of their numeric argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `cos`, `acos` - _Cosine, arccosine_ - - - - ```syntax cos x cos[x] acos x acos[x] ``` -Where `x` is a numeric, returns +Where `x` is a numeric, returns `cos` -: the [cosine](https://en.wikipedia.org/wiki/Trigonometric_functions#cosine) +: the [cosine](https://en.wikipedia.org/wiki/Trigonometric_functions#cosine) of `x`, taken to be in radians. The result is between `-1` and `1`, or null if the argument is null or infinity. `acos` @@ -41,8 +36,7 @@ q)acos -0.4 / arccosine 1.982313 ``` -`cos` and `acos` are [multithreaded primitives](../kb/mt-primitives.md). - +`cos` and `acos` are [multithreaded primitives](mt-primitives.md). ## Domain and range @@ -51,11 +45,9 @@ domain: b g x h i j e f c s p m d z n u v t range: f . f f f f f f f . f f f z f f f f ``` +## Implicit iteration - -## :fontawesome-solid-sitemap: Implicit iteration - -`cos` and `acos` are [atomic functions](../basics/atomic.md). +`cos` and `acos` are [atomic functions](atomic.md). ```q q)cos (.2;.3 .4) @@ -67,12 +59,8 @@ q)acos (.2;.3 .4) 1.266104 1.159279 ``` - - ---- -:fontawesome-solid-book: -[`sin`, `asin`](sin.md) -
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) +[`sin`, `asin`](sin.md) + +[Mathematics](math.md) diff --git a/docs/ref/count.md b/docs/ref/count.md index de56d3deb..116843d69 100644 --- a/docs/ref/count.md +++ b/docs/ref/count.md @@ -1,16 +1,12 @@ --- -title: Count the items of a list or dictionary | Reference | kdb+ and q documentation +title: Count the items of a list or dictionary | Reference | KDB-X and q documentation description: count and mcount are q keywords count returns the number of items in a list. mcount returns a moving count of the non-null items of a list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `count`, `mcount` - _Count the items of a list or dictionary_ - - - ## `count` _Number of items_ @@ -21,9 +17,9 @@ count x count[x] Where `x` is -- a list, returns the number of its items -- a dictionary, the number of items in its value -- anything else, 1 +- a list, returns the number of its items +- a dictionary, the number of items in its value +- anything else, 1 ```q q)count 0 / atom @@ -42,7 +38,7 @@ q)count ([]city:`London`Paris`Berlin; country:`England`France`Germany) q)count each ([]city:`London`Paris`Berlin; country:`England`France`Germany) 2 2 2 -q)count ({x+y}) +q)count {x+y} 1 q)count (+/) 1 @@ -51,26 +47,21 @@ q)count (+/) Use with [`each`](maps.md#each) to count the number of items at each level of a list or dictionary. ```q -q)RaggedArray:(1 2 3;4 5;6 7 8 9;0) -q)count RaggedArray +q)raggedArray:(1 2 3;4 5;6 7 8 9;0) +q)count raggedArray 4 -q)count each RaggedArray +q)count each raggedArray 3 2 4 1 -q)RaggedDict:`a`b`c!(1 2;3 4 5;"hello") -q)count RaggedDict +q)raggedDict:`a`b`c!(1 2;3 4 5;"hello") +q)count raggedDict 3 -q)count each RaggedDict +q)count each raggedDict a| 2 b| 3 c| 5 -q)\l sp.q -q)count sp -12 ``` -:fontawesome-solid-graduation-cap: -[Table counts in a partitioned database](../kb/partition.md#table-counts) - +[Table counts in a partitioned database](../how_to/interact_with_databases/partition.md#table-counts) ## `mcount` @@ -82,8 +73,8 @@ x mcount y mcount[x;y] Where -- `x` is a positive int atom -- `y` is a numeric list +- `x` is a positive int atom +- `y` is a numeric list returns the `x`-item moving counts of the non-null items of `y`. The first `x` items of the result are the counts so far, and thereafter the result is the moving count. @@ -94,15 +85,14 @@ q)3 mcount 0N 1 2 3 0N 5 0 1 2 3 2 2 ``` -`mcount` is a uniform function. - +`mcount` is a uniform function. -### :fontawesome-solid-sitemap: Implicit iteration +### Implicit iteration -`mcount` applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`mcount` applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q -q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) +q)kt:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) q)2 mcount d a| 1 1 1 @@ -115,7 +105,7 @@ a b 2 2 2 2 -q)2 mcount k +q)2 mcount kt k | a b ---| --- abc| 1 1 @@ -123,17 +113,8 @@ def| 2 2 ghi| 2 2 ``` - -:fontawesome-solid-graduation-cap: -[Sliding windows](../kb/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) - - - - +[Sliding windows](../examples/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) - - +[Mathematics](math.md) diff --git a/docs/ref/cov.md b/docs/ref/cov.md index 81f6a0347..af7592aaf 100644 --- a/docs/ref/cov.md +++ b/docs/ref/cov.md @@ -1,62 +1,59 @@ --- -title: covariance and sample covariance | Reference | kdb+ and q documentation +title: covariance and sample covariance | Reference | KDB-X and q documentation description: cov and scov are q keyword, that return respectively the covariance and sample covariance of two conforming numeric lists. --- # `cov`, `scov` _Covariance_ - - - ## `cov` ```syntax x cov y cov[x;y] ``` -Where `x` and `y` are [conforming](../basics/conformable.md) numeric lists returns their [covariance](https://en.wikipedia.org/wiki/Covariance "Wikipedia") as a floating-point number. Applies to all numeric data types and signals an error with temporal types, char and sym. +Where `x` and `y` are [conforming](conformable.md) numeric lists, returns their [covariance](https://en.wikipedia.org/wiki/Covariance "Wikipedia") as a floating-point number. Applies to all numeric data types. ```q q)2 3 5 7 cov 3 3 5 9 4.5 -q)2 3 5 7 cov 4 3 0 2 +q)t:([]a:2 3 5 7;b:4 3 0 2) +q)exec a cov b from t -1.8125 -q)select price cov size by sym from trade ``` - `cov` is an aggregate function. The function `cov` is equivalent to `{avg[x*y]-avg[x]*avg y}`. Domain and range: + ```txt - b g x h i j e f c s p m d z n u v t + B G X H I J E F C S P M D Z N U V T ---------------------------------------- -b | f . f f f f f f f . f f f f f f f f -g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f f . f f f f f f f f -h | f . f f f f f f f . f f f f f f f f -i | f . f f f f f f f . f f f f f f f f -j | f . f f f f f f f . f f f f f f f f -e | f . f f f f f f f . f f f f f f f f -f | f . f f f f f f f . f f f f f f f f -c | f . f f f f f f f . f f f f f f f f -s | . . . . . . . . . . . . . . . . . . -p | f . f f f f f f f . f f f f f f f f -m | f . f f f f f f f . f f f f f f f f -d | f . f f f f f f f . f f f f f f f f -z | f . f f f f f f f . f f f f f f f f -n | f . f f f f f f f . f f f f f f f f -u | f . f f f f f f f . f f f f f f f f -v | f . f f f f f f f . f f f f f f f f -t | f . f f f f f f f . f f f f f f f f +B | f . f f f f f f f . f f f f f f f f +G | . . . . . . . . . . . . . . . . . . +X | f . f f f f f f f . f f f f f f f f +H | f . f f f f f f f . f f f f f f f f +I | f . f f f f f f f . f f f f f f f f +J | f . f f f f f f f . f f f f f f f f +E | f . f f f f f f f . f f f f f f f f +F | f . f f f f f f f . f f f f f f f f +C | f . f f f f f f f . f f f f f f f f +S | . . . . . . . . . . . . . . . . . . +P | f . f f f f f f f . f f f f f f f f +M | f . f f f f f f f . f f f f f f f f +D | f . f f f f f f f . f f f f f f f f +Z | f . f f f f f f f . f f f f f f f f +N | f . f f f f f f f . f f f f f f f f +U | f . f f f f f f f . f f f f f f f f +V | f . f f f f f f f . f f f f f f f f +T | f . f f f f f f f . f f f f f f f f ``` Range: `f` -`cov` is a [multithreaded primitive](../kb/mt-primitives.md). +`cov` is a [multithreaded primitive](mt-primitives.md). ## `scov` @@ -66,18 +63,18 @@ _Sample covariance_ x scov y scov[x;y] ``` -Where `x` and `y` are conforming numeric lists returns their [sample covariance](https://en.wikipedia.org/wiki/Covariance#Calculating_the_sample_covariance "Wikipedia") as a float atom. +Where `x` and `y` are conforming numeric lists, returns their [sample covariance](https://en.wikipedia.org/wiki/Covariance#Calculating_the_sample_covariance "Wikipedia") as a float atom. -$$scov(x,y)=\frac{n}{n-1} cov(x,y)$$ +$$\mathrm{scov}(x,y)=\frac{n}{n-1} \mathrm{cov}(x,y)$$ Applies to all numeric data types and signals an error with temporal types, char and sym. ```q q)2 3 5 7 scov 3 3 5 9 6f -q)2 3 5 7 scov 4 3 0 2 +q)t:([]a:2 3 5 7;b:4 3 0 2) +q)exec a scov b from t -2.416667 -q)select price scov size by sym from trade ``` `scov` is an aggregate function. @@ -85,40 +82,37 @@ q)select price scov size by sym from trade The function `scov` is equivalent to `{cov[x;y]*count[x]%-1+count x}`. Domain and range: + ```txt - b g x h i j e f c s p m d z n u v t + B G X H I J E F C S P M D Z N U V T ---------------------------------------- -b | f . f f f f f f . . f f f f f f f f -g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f . . f f f f f f f f -h | f . f f f f f f . . f f f f f f f f -i | f . f f f f f f . . f f f f f f f f -j | f . f f f f f f . . f f f f f f f f -e | f . f f f f f f . . f f f f f f f f -f | f . f f f f f f f . f f f f f f f f -c | . . . . . . . f . . f f f f f f f f -s | . . . . . . . . . . . . . . . . . . -p | f . f f f f f f f . f . . . f f f f -m | f . f f f f f f f . . f . . f f f f -d | f . f f f f f f f . . . f . f f f f -z | f . f f f f f f f . . . . f f f f f -n | f . f f f f f f f . f f f f f f f f -u | f . f f f f f f f . f f f f f f f f -v | f . f f f f f f f . f f f f f f f f -t | f . f f f f f f f . f f f f f f f f +B | f . f f f f f f f . f f f f f f f f +G | . . . . . . . . . . . . . . . . . . +X | f . f f f f f f f . f f f f f f f f +H | f . f f f f f f f . f f f f f f f f +I | f . f f f f f f f . f f f f f f f f +J | f . f f f f f f f . f f f f f f f f +E | f . f f f f f f f . f f f f f f f f +F | f . f f f f f f f . f f f f f f f f +C | f . f f f f f f f . f f f f f f f f +S | . . . . . . . . . . . . . . . . . . +P | f . f f f f f f f . f f f f f f f f +M | f . f f f f f f f . f f f f f f f f +D | f . f f f f f f f . f f f f f f f f +Z | f . f f f f f f f . f f f f f f f f +N | f . f f f f f f f . f f f f f f f f +U | f . f f f f f f f . f f f f f f f f +V | f . f f f f f f f . f f f f f f f f +T | f . f f f f f f f . f f f f f f f f ``` Range: `f` -`scov` is a [multithreaded primitive](../kb/mt-primitives.md). - +`scov` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book: + [`var, svar`](var.md)
-:fontawesome-solid-book: -[Mathematics](../basics/math.md) -
-:fontawesome-brands-wikipedia-w: -[Covariance](https://en.wikipedia.org/wiki/Covariance) + +[Mathematics](math.md) diff --git a/docs/ref/cross.md b/docs/ref/cross.md index e0000c5ad..4f9818ab8 100644 --- a/docs/ref/cross.md +++ b/docs/ref/cross.md @@ -1,17 +1,17 @@ --- -title: cross product | Reference | kdb+ and q documentation +title: cross product | Reference | KDB-X and q documentation description: cross is a q keyword that returns the cross-product (all possible combinations) of the items of its arguments. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `cross` - +_Cross product_ ```syntax x cross y cross[x;y] ``` -Returns the cross-product (i.e. all possible combinations) of `x` and `y`. +Returns the [cross (or Cartesian) product](https://en.wikipedia.org/wiki/Cartesian_product "Wikipedia") (that is, all possible pairings) of lists `x` and `y`. ```q q)1 2 3 cross 10 20 @@ -21,6 +21,11 @@ q)1 2 3 cross 10 20 2 20 3 10 3 20 +``` + +Use `(cross/)` to create the cross product of 3 or more lists. + +```q q)(cross/)(2 3;10;"abc") 2 10 "a" 2 10 "b" @@ -30,7 +35,7 @@ q)(cross/)(2 3;10;"abc") 3 10 "c" ``` -`cross` can work on tables and dictionaries. +`cross` can work on tables and dictionaries. ```q q)s:`IBM`MSFT`AAPL @@ -46,5 +51,37 @@ AAPL 1 AAPL 2 ``` +The function `cross` is equivalent to `{raze x,/:\:y}`. + +!!! note + + As a result of this equivalence and the way the [Join operator (`,`)](join.md) works, if the items of `x` and `y` are lists themselves, they are joined together with no regards to the extra level of nesting. -The function `cross` is equivalent to `{raze x,/:\:y}`. \ No newline at end of file + ```q + q)a:(1 2;3 4) cross (5 6;7 8) + 1 2 5 6 + 1 2 7 8 + 3 4 5 6 + 3 4 7 8 + ``` + + To keep the nesting, `enlist` the sublists. + + ```q + q)b:(enlist each (1 2;3 4)) cross enlist each (5 6;7 8) + 1 2 5 6 + 1 2 7 8 + 3 4 5 6 + 3 4 7 8 + ``` + + Although they are displayed identically, the two results are not the same! + + ```q + q)-1 .Q.s1 (1 2;3 4) cross (5 6;7 8); + (1 2 5 6;1 2 7 8;3 4 5 6;3 4 7 8) + q)-1 .Q.s1 (enlist each (1 2;3 4)) cross enlist each (5 6;7 8); + ((1 2;5 6);(1 2;7 8);(3 4;5 6);(3 4;7 8)) + ``` + +--- diff --git a/docs/ref/csv.md b/docs/ref/csv.md index 96fb41b90..59ec05742 100644 --- a/docs/ref/csv.md +++ b/docs/ref/csv.md @@ -1,26 +1,22 @@ --- -title: csv – Reference – kdb+ and q documentation +title: csv – Reference – KDB-X and q documentation description: csv is a q keyword that represents the delimiter of CSV files. -author: Stephen Taylor -keywords: comma, comma-separated values, csv, file, kdb+, q, text +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: comma, comma-separated values, csv, file, KDB-X, q, text --- -# `csv` +# `csv` _CSV delimiter_ - - ```syntax csv ``` -A synonym for `","` for use in preparing text for CSV files, or reading them. +A synonym for `","` for use in preparing text for CSV files, or reading them. -:fontawesome-solid-book: [Prepare Text](file-text.md#prepare-text), -[`.h.cd`](doth.md#hcd-csv-from-data) (csv from data), +[`.h.cd`](doth.md#hcd-csv-from-data) (csv from data), [`.h.td`](doth.md#htd-tsv-from-data) (tsv from data)
-:fontawesome-solid-book-open: -[File system](../basics/files.md) +[File system](files.md) diff --git a/docs/ref/cut.md b/docs/ref/cut.md index 412e50659..8e0ab1897 100644 --- a/docs/ref/cut.md +++ b/docs/ref/cut.md @@ -1,15 +1,11 @@ --- -title: Cut, cut – Reference – kdb+ and q documentation +title: Cut, cut – Reference – KDB-X and q documentation description: Cut is a q operator that cuts a list or table into subarrays. cut is a q keyword that cuts a list or table into a matrix into a specified number of columns. -author: Stephen Taylor -keywords: cut, kdb+, keyword, operator, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: cut, KDB-X, keyword, operator, q --- # `_` Cut, `cut` - - - - ## _ (cut operator) _Cut a list or table into sub-arrays_ @@ -18,58 +14,51 @@ _Cut a list or table into sub-arrays_ x _ y _[x;y] ``` -Where +Where -- `x` is a **non-decreasing list of integers** in the domain `til count y` -- `y` is a list or table +- `x` is a **non-decreasing list of integers** in the domain `til count y` +- `y` is a list or table -returns `y` cut at the indexes given in `x`. The result is a list with the same count as `x`. +returns `y` cut at the indexes given in `x`. The result is a list with the same count as `x`. Refer to the examples for how exactly the cut is constructed: -Examples using cut on lists: ```q q)2 4 9 _ til 10 /first result item starts at index 2 2 3 4 5 6 7 8 ,9 -q) q)2 4 4 9 _ til 10 /cuts are empty for duplicate indexes 2 3 `long$() 4 5 6 7 8 ,9 -q)2 5 7 _ til 12 -2 3 4 -5 6 -7 8 9 10 11 -``` -Example using cut on table `sp` created using [`sp.q`](https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q) -```q -q)\l sp.q -q)count sp -12 -q){}show each 2 5 7_sp / `show` returns the generic null :: -s p qty ---------- -s1 p3 400 -s1 p4 200 -s4 p5 100 -s p qty ---------- -s1 p6 100 -s2 p1 300 -s p qty ---------- -s2 p2 400 -s3 p2 200 -s4 p2 200 -s4 p4 300 -s1 p5 400 +q)t:([]a:til 5;b:`a`b`c`d`e) +q)ts:0 3 _ t +q)ts 0 +a b +--- +0 a +1 b +2 c +q)ts 1 +a b +--- +3 d +4 e ``` -`_`(cut) is a [multithreaded primitive](../kb/mt-primitives.md). +!!! tip + If you want all list items to be returned, be sure to start the left argument with 0: -!!! tip "Avoid confusion with underscores in names: separate the Cut operator with spaces." + ```q + q)0 4 5 _ til 7 + 0 1 2 3 + ,4 + 5 6 + ``` +`_`(cut) is a [multithreaded primitive](mt-primitives.md). + +!!! tip "Avoid confusion with underscores in names: separate the Cut operator with spaces." ## `cut` (keyword) @@ -79,10 +68,10 @@ _Cut a list or table into a matrix of `x` columns_ x cut y cut[x;y] ``` -Where +Where -- `x` is an **integer atom** -- `y` is a list +- `x` is an **integer atom** +- `y` is a list returns `y` splits into a list of lists, all (except perhaps the last) of count `x`. @@ -95,8 +84,6 @@ q)4 cut til 10 Otherwise `cut` behaves as [`_` Cut](#_-cut-operator). - ---- -:fontawesome-solid-book: [Drop](drop.md) diff --git a/docs/ref/deal.md b/docs/ref/deal.md index 5c28dc239..70759570b 100644 --- a/docs/ref/deal.md +++ b/docs/ref/deal.md @@ -1,7 +1,7 @@ --- -title: Roll, Deal, Permute | Reference | kdb+ and q documentation +title: Roll, Deal, Permute | Reference | KDB-X and q documentation description: Roll, Deal, and Permute are q operators that return ran dom selections, with or without duplicates -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited date: July 2019 keywords: deal, duplicate, generate, permute, rand, random, seed --- @@ -170,7 +170,7 @@ q)0N?("the";1 2 4;`ibm`goog) / permute items ## Seed -Deal, Roll, Permute and [`rand`](rand.md) use a constant seed on kdb+ startup: scripts using them can be repeated with the same results. You can see and set the value of the seed with system command [`\S`](../basics/syscmds.md#s-random-seed).) +Deal, Roll, Permute and [`rand`](rand.md) use a constant seed on KDB-X startup: scripts using them can be repeated with the same results. You can see and set the value of the seed with system command [`\S`](syscmds.md#s-random-seed).) !!! tip "To use GUIDs as identifiers, use Deal, not Roll" @@ -208,11 +208,11 @@ type | `x` is negative (Roll only) ---- -:fontawesome-solid-book: + [`rand`](rand.md)
-:fontawesome-solid-book-open: -[system command `\S`](../basics/syscmds.md#s-random-seed) + +[system command `\S`](syscmds.md#s-random-seed)
-:fontawesome-solid-book-open: -[command-line option `-S`](../basics/cmdline.md#-s-random-seed) + +[command-line option `-S`](cmdline.md#-s-random-seed) diff --git a/docs/ref/delete.md b/docs/ref/delete.md index cb505a8c8..b55f0c937 100644 --- a/docs/ref/delete.md +++ b/docs/ref/delete.md @@ -1,8 +1,8 @@ --- -title: delete query | Reference | kdb+ and q documentation +title: delete query | Reference | KDB-X and q documentation description: delete is a qSQL template that removes rows or columns from a table, entries from a dictionary, or objects from a namespace. -author: Stephen Taylor -keywords: delete, functional kdb+, q, query, qsql, sql +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: delete, functional KDB-X, q, query, qsql, sql --- # `delete` @@ -14,11 +14,11 @@ delete from x where pw delete ps from x ``` -!!! info "`delete` is a [qSQL query template](../basics/qsql.md) and varies from regular q syntax" +!!! info "`delete` is a [qSQL query template](qsql.md) and varies from regular q syntax" For the Delete operator `!`, see -:fontawesome-solid-book-open: -[Functional SQL](../basics/funsql.md#delete) + +[Functional SQL](funsql.md#delete) ## Table rows @@ -104,8 +104,8 @@ c| 2 Enclose in a lambda or use [Vector Conditional](vector-conditional.md) instead. - :fontawesome-regular-hand-point-right: - [qSQL](../basics/qsql.md#cond) + + [qSQL](qsql.md#cond) ## Namespace objects @@ -131,6 +131,6 @@ q)\v `symbol$() ``` -:fontawesome-regular-hand-point-right: -[qSQL](../basics/qsql.md) + +[qSQL](qsql.md) diff --git a/docs/ref/deltas.md b/docs/ref/deltas.md index 9d1f1730e..73ee77d3d 100644 --- a/docs/ref/deltas.md +++ b/docs/ref/deltas.md @@ -1,54 +1,72 @@ --- -title: deltas – differences between adjacent list items | Reference | kdb+ and q documentation +title: deltas – differences between adjacent list items | Reference | KDB-X and q documentation description: deltas is a q keyword that returns the differences between adjacent list items. -keywords: diff, difference, item, kdb+, list, q +keywords: diff, difference, item, KDB-X, list, q --- # `deltas` _Differences between adjacent list items_ - - - - ```syntax deltas x deltas[x] ``` -Where `x` is a numeric or temporal vector, returns differences between consecutive pairs of its items. +Where `x` is a numeric or temporal vector, returns differences between consecutive pairs of its items, with the first item of the result being the first item of `x`. ```q q)deltas 1 4 9 16 1 3 5 7 +q)t:([]time:2020.01.01D09:00:00+1000*til 6; sym:`GOOG`AAPL`AAPL`GOOG`AAPL`GOOG; price:51 54 54 52 53 53) +q)show t:update diff:deltas price by sym from t +time sym price diff +--------------------------------------------- +2020.01.01D09:00:00.000000000 GOOG 51 51 +2020.01.01D09:00:00.000001000 AAPL 54 54 +2020.01.01D09:00:00.000002000 AAPL 54 0 +2020.01.01D09:00:00.000003000 GOOG 52 1 +2020.01.01D09:00:00.000004000 AAPL 53 -1 +2020.01.01D09:00:00.000005000 GOOG 53 1 ``` -In a query to get price movements: - -```q -update diff:deltas price by sym from trade -``` - -With [`signum`](signum.md) to count the number of up/down/same ticks: +Use with [`signum`](signum.md) to count the number of up/down/same ticks: ```q -q)select count i by signum deltas price from trade -price| x ------| ---- --1 | 247 -0 | 3 -1 | 252 +// the sign of the price movements +q)select movement:signum deltas price by sym from t +sym | movement +----| -------- +AAPL| 1 0 -1 +GOOG| 1 1 1 +// it always starts with 1, so we will drop that +q)select movement:1_ signum deltas price by sym from t +sym | movement +----| -------- +AAPL| 0 -1 +GOOG| 1 1 +// ungroup so we can do a second query more easily +q)ungroup select movement:1_ signum deltas price by sym from t +sym movement +------------- +AAPL 0 +AAPL -1 +GOOG 1 +GOOG 1 +q)select count i by sym, movement from ungroup select movement:1_ signum deltas price by sym from t +sym movement| x +-------------| - +AAPL -1 | 1 +AAPL 0 | 1 +GOOG 1 | 2 ``` - ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: i . i i i j e f . . n i i f n u v t ``` - ## First predecessor -The predecessor of the first item is 0. +The predecessor of the first item is 0. ```q q)deltas 2000 2005 2007 2012 2020 @@ -70,13 +88,9 @@ q)deltas0 2000 2005 2007 2012 2020 However, `deltas` is supported only as a unary function. For binary application, use the derived function. - - ---- -:fontawesome-solid-book: -[`deltas`](deltas.md), -[`differ`](differ.md), -[Each Prior](maps.md#each-prior), -[`ratios`](ratios.md) - +[`deltas`](deltas.md), +[`differ`](differ.md), +[Each Prior](maps.md#each-prior), +[`ratios`](ratios.md) diff --git a/docs/ref/desc.md b/docs/ref/desc.md index 5d176cfa7..0a698161e 100644 --- a/docs/ref/desc.md +++ b/docs/ref/desc.md @@ -1,18 +1,13 @@ --- -title: desc, idesc, xdesc – descending sorts | Reference | kdb+ and q documentation +title: desc, idesc, xdesc – descending sorts | Reference | KDB-X and q documentation description: Descending sorts in q; desc returns a list sorted descending; idesc returns the grade for that sort. xdesc sorts a table descending by specified columns. -author: Stephen Taylor -keywords: asc, desc, descending, grade, idesc, kdb+, q, sort, xdesc +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: asc, desc, descending, grade, idesc, KDB-X, q, sort, xdesc --- # `desc`, `idesc`, `xdesc` _Sort and grade: descending_ - - - -!!! info "Q chooses from a variety of algorithms, depending on the type and data distribution." - ## `desc` _Descending sort_ @@ -21,50 +16,53 @@ _Descending sort_ desc x desc[x] ``` -Returns `x` sorted into descending order. -The function is uniform. -The sort is stable: it preserves order between equals. - Where `x` is a -- **vector**, it is returned sorted -- **mixed list**, the result is sorted within datatype -- **dictionary**, returns it sorted by the values -- **table**, returns it sorted by the first non-key column and with the sorted attribute set on that column +- **vector**, returns its items in descending order of value; +- **mixed list**, returns the items sorted descending by datatype, then descending within datatype; +- **nested list**, returns the items sorted descending lexicographically; +- **dictionary**, returns it sorted by the values; +- **table**, returns it sorted desceding lexicographically by the non-key columns. + +!!! info "Q chooses from a variety of sorting algorithms depending on the datatype and data distribution." -!!! detail "Unlike `asc`, which sets the parted attribute where there are other non-key columns, `desc` sets only the sorted attribute." +!!! detail "Unlike `asc`, which sets the sorted (or parted) attribute, `desc` sets none, as there is no attribute that would indicate a descending sort." ```q -q)desc 2 1 3 4 2 1 2 / vector +q)desc 2 1 3 4 2 1 2 / vector 4 3 2 2 2 1 1 -q)desc (1;1b;"b";2009.01.01;"a";0) / mixed list +q)show l:desc (1;1b;"b";2009.01.01;"a";0) / mixed list 2009.01.01 "b" "a" 1 0 +q)type each l +-14 -10 -10 -7 -7 -1h / datatypes are sorted by their type number -q)desc `a`b`c!2 1 3 / dictionary +q)desc `a`b`c!2 1 3 / dictionary c| 3 a| 2 b| 1 -q)desc([]a:3 4 1;b:`a`d`s) / table +q)desc([]a:4 4 1;b:`a`d`s) / table a b --- 4 d -3 a +4 a 1 s + q)meta desc([]a:3 4 1;b:`a`d`s) c| t f a -| ----- a| j b| s ``` + ```txt -domain: b g x h i j e f c s p m d z n u v t -range: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T +range: B G X H I J E F C S P M D Z N U V T ``` ## `idesc` @@ -75,7 +73,7 @@ _Descending grade_ idesc x idesc[x] ``` -Where `x` is a list or dictionary, returns the indices needed to sort list it in descending order. +Where `x` is a list or dictionary, returns the indices needed to sort it in descending order. ```q q)L:2 1 3 4 2 1 2 @@ -88,16 +86,15 @@ q)(desc L)~L idesc L q)idesc `a`c`b!1 2 3 `b`c`a ``` + ```txt -domain: b g x h i j e f c s p m d z n u v t -range: j j j j j j j j j j j j j j j j j j +domain: B G X H I J E F C S P M D Z N U V T +range: J J J J J J J J J J J J J J J J J J ``` - ## `xdesc` -_Sorts a table in descending order of specified columns. -The sort is by the first column specified, then by the second column within the first, and so on._ +_Sorts a table in descending order of specified columns._ ```syntax x xdesc y xdesc[x;y] @@ -105,47 +102,56 @@ x xdesc y xdesc[x;y] Where `x` is a symbol vector of column names defined in `y`, which is passed by -- value, returns -- reference, updates +- value, returns +- reference, updates -`y` sorted in descending order by `x`. +`y` sorted in descending order by `x`. The sorted attribute is not set. The sort is stable, i.e. it preserves order amongst equals. ```q -q)\l sp.q -q)s -s | name status city ---| ------------------- -s1| smith 20 london -s2| jones 10 paris -s3| blake 30 paris -s4| clark 20 london -s5| adams 30 athens -q)`city xdesc s / sort descending by city -s | name status city ---| ------------------- -s2| jones 10 paris -s3| blake 30 paris -s1| smith 20 london -s4| clark 20 london -s5| adams 30 athens -q)meta `city xdesc s / `s# attribute not set -c | t f a -------| ----- -s | s -name | s -status| i -city | s +q)show t:0N?([]sym:raze 2#/:`a`b`c; date:6#2025.01.01+til 2; val:50+6?10f) +sym date val +----------------------- +c 2025.01.01 51.95847 +a 2025.01.02 53.40721 +b 2025.01.01 50.54001 +b 2025.01.02 55.49794 +a 2025.01.01 53.83946 +c 2025.01.02 55.61526 +q)`date xdesc t +sym date val +----------------------- +a 2025.01.02 53.40721 +b 2025.01.02 55.49794 +c 2025.01.02 55.61526 +c 2025.01.01 51.95847 +b 2025.01.01 50.54001 +a 2025.01.01 53.83946 +q)`sym`date xdesc t +sym date val +----------------------- +c 2025.01.02 55.61526 +c 2025.01.01 51.95847 +b 2025.01.02 55.49794 +b 2025.01.01 50.54001 +a 2025.01.02 53.40721 +a 2025.01.01 53.83946 +q)`sym`date xdesc `t +`t +q)meta t / no attribute set +c | t f a +----| ----- +sym | s +date| d +val | f ``` +**Duplicate column names** +`xdesc` signals `'dup` and the duplicate column name if it finds duplicate columns in the right argument. (Since V3.6 2019.02.19.) -**Duplicate column names** `xdesc` signals `dup` if it finds duplicate columns in the right argument. (Since V3.6 2019.02.19.) - -:fontawesome-regular-hand-point-right: -[`.Q.id` (sanitize)](dotq.md#id-sanitize) - +[`.Q.id` (sanitize)](dotq.md#id-sanitize) ### Sorting data on disk @@ -155,16 +161,15 @@ city | s ---- -:fontawesome-solid-book: [`asc`, `iasc`, `xasc`](asc.md), [`attr`](attr.md), [Set Attribute](set-attribute.md)
-:fontawesome-solid-book-open: -[Dictionaries & tables](../basics/dictsandtables.md), -[Metadata](../basics/metadata.md), -[Sorting](../basics/by-topic.md#sort) + +[Dictionaries & tables](dictsandtables.md), +[Metadata](metadata.md), +[Sorting](by-topic.md#sort)
-_Q for Mortals_ -[§8.8 Attributes](/q4m3/8_Tables/#88-attributes) +_Q for Mortals_ +[§8.8 Attributes](../learn/q4m/8_Tables.md/#89-attributes) diff --git a/docs/ref/dev.md b/docs/ref/dev.md index 3467f77f9..79469efa3 100644 --- a/docs/ref/dev.md +++ b/docs/ref/dev.md @@ -1,15 +1,12 @@ --- -title: dev, mdev, sdev – standard, moving, and sample standard deviations | Reference | kdb+ and q documentation +title: dev, mdev, sdev – standard, moving, and sample standard deviations | Reference | KDB-X and q documentation description: dev, mdev, and sdev are q keywords that return, respectively, the standard deviation, moving deviation, and sample standard deviation of their argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `dev`, `mdev`, `sdev` _Deviations_ - - - ## `dev` _Standard deviation_ @@ -18,8 +15,8 @@ _Standard deviation_ dev x dev[x] ``` -Where `x` is a numeric list, returns its [standard deviation](https://en.wikipedia.org/wiki/Standard_deviation "Wikipedia") (as the square root of the variance). -Applies to all numeric data types and signals an error with temporal types, char and sym. +Where `x` is a numeric list, returns its [standard deviation](https://en.wikipedia.org/wiki/Standard_deviation "Wikipedia") (the square root of the variance). +Applies to all numeric data types. ```q q)dev 10 343 232 55 @@ -29,11 +26,11 @@ q)dev 10 343 232 55 `dev` is an aggregate function, equivalent to `{sqrt var x}`. ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: f . f f f f f f f . f f f f f f f f ``` -Since 4.1t 2022.04.15, can also traverse columns of tables and general/anymap/nested lists. +Since 4.1t 2022.04.15, it can also traverse columns of tables and general/anymap/nested lists. ```q q)M:get`:m77 set m:(2 3;4 0N;1 7) @@ -50,7 +47,7 @@ a| 1.247219 b| 2 ``` -`dev` is a [multithreaded primitive](../kb/mt-primitives.md). +`dev` is a [multithreaded primitive](mt-primitives.md). ## `mdev` @@ -62,17 +59,17 @@ x mdev y mdev[x;y] Where -- `x` is a positive int atom -- `y` is a numeric list +- `x` is a positive int atom +- `y` is a numeric list -returns the floating-point `x`-item moving deviations of `y`, with any nulls after the first item replaced by zero. The first `x` items of the result are the deviations of the terms so far, and thereafter the result is the moving deviation. +returns the floating-point `x`-item moving deviations of `y`, with any nulls replaced by zero. The first `x` items of the result are the deviations of the terms so far, and thereafter the result is the moving deviation. If the first item of `y` is null, the first item of the result is also null. ```q q)2 mdev 1 2 3 5 7 10 0 0.5 0.5 1 1 1.5 q)5 mdev 1 2 3 5 7 10 0 0.5 0.8164966 1.47902 2.154066 2.87054 -q)5 mdev 0N 2 0N 5 7 0N / nulls after the first are replaced by 0 +q)5 mdev 0N 2 0N 5 7 0N / the first item is null 0n 0 0 1.5 2.054805 2.054805 q)t @@ -91,38 +88,38 @@ b c `mdev` is a uniform function. Domain and range: + ```txt - b g x h i j e f c s p m d z n u v t ----------------------------------------- -b | f . f f f f f f f . f f f f f f f f -g | . . . . . . . . . . . . . . . . . . -x | f . f f f f f f f . f f f f f f f f -h | f . f f f f f f f . f f f f f f f f -i | f . f f f f f f f . f f f f f f f f -j | f . f f f f f f f . f f f f f f f f -e | . . . . . . . . . . . . . . . . . . -f | . . . . . . . . . . . . . . . . . . -c | . . . . . . . . . . . . . . . . . . -s | . . . . . . . . . . . . . . . . . . -p | . . . . . . . . . . . . . . . . . . -m | . . . . . . . . . . . . . . . . . . -d | . . . . . . . . . . . . . . . . . . -z | . . . . . . . . . . . . . . . . . . -n | . . . . . . . . . . . . . . . . . . -u | . . . . . . . . . . . . . . . . . . -v | . . . . . . . . . . . . . . . . . . -t | . . . . . . . . . . . . . . . . . . + | B G X H I J E F C S P M D Z N U V T +-| ----------------------------------- +b| F . F F F F F F F . F F F F F F F F +g| . . . . . . . . . . . . . . . . . . +x| F . F F F F F F F . F F F F F F F F +h| F . F F F F F F F . F F F F F F F F +i| F . F F F F F F F . F F F F F F F F +j| F . F F F F F F F . F F F F F F F F +e| . . . . . . . . . . . . . . . . . . +f| . . . . . . . . . . . . . . . . . . +c| . . . . . . . . . . . . . . . . . . +s| . . . . . . . . . . . . . . . . . . +p| . . . . . . . . . . . . . . . . . . +m| . . . . . . . . . . . . . . . . . . +d| . . . . . . . . . . . . . . . . . . +z| . . . . . . . . . . . . . . . . . . +n| . . . . . . . . . . . . . . . . . . +u| . . . . . . . . . . . . . . . . . . +v| . . . . . . . . . . . . . . . . . . +t| . . . . . . . . . . . . . . . . . . ``` -Range: `f` - +Range: `F` -### :fontawesome-solid-sitemap: Implicit iteration +### Implicit iteration -`mdev` applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`mdev` applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q -q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) +q)kt:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) q)2 mdev d a| 0 0 0 @@ -135,7 +132,7 @@ a b 5.5 0.5 9 0.5 -q)2 mdev k +q)2 mdev kt k | a b ---| ------- abc| 0 0 @@ -143,7 +140,6 @@ def| 5.5 0.5 ghi| 9 0.5 ``` - ## `sdev` _Sample standard deviation_ @@ -152,9 +148,9 @@ _Sample standard deviation_ sdev x sdev[x] ``` -Where `x` is a numeric list, returns its sample standard deviation as the square root of the [sample variance](var.md#svar). +Where `x` is a numeric list, returns its sample standard deviation, the square root of the [sample variance](var.md#svar). -$$sdev(x)=\sqrt{\frac{n}{n-1}var(x)}$$ +$$\mathrm{sdev}(x)=\sqrt{\frac{n}{n-1}\mathrm{var}(x)}$$ ```q q)sdev 10 343 232 55 @@ -164,11 +160,11 @@ q)sdev 10 343 232 55 `sdev` is an aggregate function, equivalent to `{sqrt var[x]*count[x]%-1+count x}`. ```txt -domain: b g x h i j e f c s p m d z n u v t +domain: B G X H I J E F C S P M D Z N U V T range: f . f f f f f f f . f f f f f f f f ``` -Since 4.1t 2022.04.15, can also traverse columns of tables and general/anymap/nested lists. +Since 4.1t 2022.04.15, it can also traverse columns of tables and general/anymap/nested lists. ```q q)M:get`:m77 set m:(2 3;4 0N;1 7) @@ -185,21 +181,18 @@ a| 1.527525 b| 2.828427 ``` -`sdev` is a [multithreaded primitive](../kb/mt-primitives.md). +`sdev` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book: + [`var`, `svar`](var.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-solid-graduation-cap: -[Sliding windows](../kb/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) + +[Sliding windows](../examples/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window)
-:fontawesome-brands-wikipedia-w: + [Standard deviation](https://en.wikipedia.org/wiki/Standard_deviation "Wikipedia"), [Variance](https://en.wikipedia.org/wiki/Variance "Wikipedia") -
-:fontawesome-solid-globe: -[Standard deviation](http://financereference.com/learn/standard-deviation "financereference.com") diff --git a/docs/ref/dict.md b/docs/ref/dict.md index 734874ba4..73b90c387 100644 --- a/docs/ref/dict.md +++ b/docs/ref/dict.md @@ -1,8 +1,8 @@ --- -title: Dict | Reference | kdb+ and q documentation +title: Dict | Reference | KDB-X and q documentation description: Dict is a q operator that returns a dictionary from vectors of keys and values. -author: Stephen Taylor -keywords: bang, dict, dictionaries, dictionary, kdb+, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: bang, dict, dictionaries, dictionary, KDB-X, q --- # `!` Dict @@ -67,13 +67,13 @@ length | `x` and `y` are not same-length lists length | `x` is not in `1_ til count y` type | `y` is not a simple table -:fontawesome-solid-book: + [`key`](key.md), [`value`](value.md)
-:fontawesome-solid-book-open: -[Dictionaries & tables](../basics/dictsandtables.md) + +[Dictionaries & tables](dictsandtables.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§5 Dictionaries](/q4m3/5_Dictionaries/) \ No newline at end of file +[§5 Dictionaries](../learn/q4m/5_Dictionaries.md/) \ No newline at end of file diff --git a/docs/ref/differ.md b/docs/ref/differ.md index 67b7f1516..c2dc4b78d 100644 --- a/docs/ref/differ.md +++ b/docs/ref/differ.md @@ -1,65 +1,67 @@ --- -title: differ – Reference – kdb+ and q documentation +title: differ – Reference – KDB-X and q documentation description: differ is a q keyword that flags where items of a list change value. -author: Stephen Taylor -keywords: diff, differ, kdb+, item, list, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: diff, differ, KDB-X, item, list, q --- # `differ` _Find where list items change value_ - - - ```syntax differ x differ[x] ``` -Returns a boolean list indicating where consecutive pairs of items in `x` differ. -It applies to all data types. +Returns a boolean list indicating where consecutive pairs of items in `x` differ. +It applies to all data types. -It is a uniform function. -The first item of the result is always `1b`: +`differ` is a uniform function. +The first item of the result is always `1b`. ```txt r[i]=1b for i=0 r[i]=not A[i]~A[i-1] otherwise ``` + ```q q)differ`IBM`IBM`MSFT`CSCO`CSCO 10110b q)differ 1 3 3 4 5 6 6 1101110b +q)differ (7;`a;`a;09:34) +1101b ``` -Split a table with multiple dates into a list of tables with distinct dates. - -```q -q)d:2009.10.01+asc 100?30 -q)s:100?`IBM`MSFT`CSCO -q)t:([]date:d;sym:s;price:100?100f;size:100?1000) -q)i:where differ t[`date] / indices where dates differ -q)tlist:i _ t / list of tables with one date per table -q)tlist 0 -date sym price size ------------------------------ -2009.10.01 IBM 37.95179 710 -2009.10.01 CSCO 52.908 594 -2009.10.01 MSFT 32.87258 250 -2009.10.01 CSCO 75.15704 592 -q)tlist 1 -date sym price size ----------------------------- -2009.10.02 MSFT 18.9035 26 -2009.10.02 CSCO 12.7531 760 -``` +!!! tip + + Combine with [Cut (`_`)](cut.md) to split a table with multiple dates into a list of tables with distinct dates. + + ```q + q)d:2009.10.01+asc 100?30 + q)s:100?`IBM`MSFT`CSCO + q)t:([]date:d;sym:s;price:100?100f;size:100?1000) + q)i:where differ t[`date] / indices where dates differ + q)tlist:i _ t / list of tables with one date per table + q)tlist 0 + date sym price size + ----------------------------- + 2009.10.01 IBM 37.95179 710 + 2009.10.01 CSCO 52.908 594 + 2009.10.01 MSFT 32.87258 250 + 2009.10.01 CSCO 75.15704 592 + q)tlist 1 + date sym price size + ---------------------------- + 2009.10.02 MSFT 18.9035 26 + 2009.10.02 CSCO 12.7531 760 + ``` ```txt -domain: b g x h i j e f c s p m d z n u v t -range: b b b b b b b b b b b b b b b b b b +domain: B G X H I J E F C S P M D Z N U V T +range: B B B B B B B B B B B B B B B B B B ``` -`differ` is a [multithreaded primitive](../kb/mt-primitives.md). +`differ` is a [multithreaded primitive](mt-primitives.md). ??? warning "Binary use deprecated" @@ -70,5 +72,5 @@ range: b b b b b b b b b b b b b b b b b b For a binary version, use Match Each Prior: `~:'`. --- -:fontawesome-regular-hand-point-right: -Basics: [Comparison](../basics/comparison.md) + +[Comparison](comparison.md) diff --git a/docs/ref/display.md b/docs/ref/display.md index 7560fba91..bf553826d 100644 --- a/docs/ref/display.md +++ b/docs/ref/display.md @@ -1,8 +1,8 @@ --- -title: Display – Reference – kdb+ and q documentation +title: Display – Reference – KDB-X and q documentation description: Display is a q operator that writes a value to the console before returning it. -author: Stephen Taylor -keywords: bang, console, debug, display, kdb+ +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: bang, console, debug, display, KDB-X --- # `!` Display @@ -25,8 +25,8 @@ q)2+0N!3 Useful for debugging, or avoiding formatting that obscures the data’s structure. --- -:fontawesome-solid-book: + [`show`](show.md)
-:fontawesome-solid-book-open: -[Debugging](../basics/debug.md) \ No newline at end of file + +[Debugging](../how_to/working-with-code/debug.md) \ No newline at end of file diff --git a/docs/ref/distinct.md b/docs/ref/distinct.md index 25e018ac8..2976666d8 100644 --- a/docs/ref/distinct.md +++ b/docs/ref/distinct.md @@ -1,28 +1,25 @@ --- -title: distinct – unique items of a list | Reference | kdb+ and q documentation +title: distinct – unique items of a list | Reference | KDB-X and q documentation description: distinct is a q keyword that returns the nub (the unique items) of a list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `distinct` - - - _Unique items of a list_ ```syntax distinct x distinct[x] ``` -Where `x` is a list returns the distinct (unique) items of `x` in the order of their first occurrence. -The result does _not_ have the [unique attribute](set-attribute.md) set. +Where `x` is a list, returns the distinct (unique) items of `x` in the order of their first occurrence. +The result does _not_ have the [unique attribute](set-attribute.md) set. ```q q)distinct 2 3 7 3 5 3 2 3 7 5 ``` -Returns the distinct rows of a table. +For a table, its distinct rows are returned. ```q q)distinct flip `a`b`c!(1 2 1;2 3 2;"aba") @@ -32,7 +29,7 @@ a b c 2 3 b ``` -It does not use [comparison tolerance](../basics/precision.md) +It does not use [comparison tolerance](precision.md) ```q q)\P 14 @@ -40,8 +37,12 @@ q)distinct 2 + 0f,10 xexp -13 2 2.0000000000001 ``` -`distinct` is a [multithreaded primitive](../kb/mt-primitives.md). +`distinct` is a [multithreaded primitive](mt-primitives.md). +```txt +domain: B G X H I J E F C S P M D Z N U V T +range: B G X H I J E F C S P M D Z N U V T +``` ## Errors @@ -49,12 +50,10 @@ error | cause ------|---------------- type | `x` is an atom - ---- -:fontawesome-solid-book: [`.Q.fu`](dotq.md#fu-apply-unique) (apply unique)
-:fontawesome-solid-book-open: -[Precision](../basics/precision.md), -[Search](../basics/by-topic.md#search) + +[Precision](precision.md), +[Search](by-topic.md#search) diff --git a/docs/ref/div.md b/docs/ref/div.md index a2f989391..f71daf549 100644 --- a/docs/ref/div.md +++ b/docs/ref/div.md @@ -1,14 +1,11 @@ --- -title: div | Reference | kdb+ and q documentation +title: div | Reference | KDB-X and q documentation description: div is a q keyword that performs integer division. -author: Stephen Taylor -keywords: div, divide, division, in, integer, kdb+, math, mathematics, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: div, divide, division, in, integer, KDB-X, math, mathematics, q --- # `div` - - - _Integer division_ ```syntax @@ -40,7 +37,7 @@ q)2014.10.13 div 365 2000.01.15 ``` -The exceptions are char, byte, short, and real, which get converted to ints. +The exceptions get converted to ints. ```q q)7h div 3 @@ -51,12 +48,11 @@ q)"\023" div 8 2i ``` -`div` is a [multithreaded primitive](../kb/mt-primitives.md). - +`div` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`div` is an [atomic function](../basics/atomic.md). +`div` is an [atomic function](atomic.md). ```q q)(10;20 30)div(3 4; -5) @@ -64,16 +60,16 @@ q)(10;20 30)div(3 4; -5) -4 -6 ``` -It applies to [dictionaries and keyed tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and keyed tables](math.md#dictionaries-and-tables). ```q -q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) +q)kt:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) q)d div 5 a| 2 -5 0 b| 0 1 -2 -q)k div 5 +q)kt div 5 k | a b ---| ----- abc| 2 0 @@ -81,43 +77,42 @@ def| -5 1 ghi| 0 -2 ``` - ## Domain and range The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt - b g x h i j e f c s p m d z n u v t ----------------------------------------- -b | i . i i i i i i i . i i i i i i i i -g | . . . . . . . . . . . . . . . . . . -x | i . i i i i i i i . i i i i i i i i -h | i . i i i i i i i . i i i i i i i i -i | i . i i i i i i i . i i i i i i i i -j | j . j j j j j j j . j j j j j j j j -e | f . f f f f f f f . f f f f f f f f -f | f . f f f f f f f . f f f f f f f f -c | i . i i i i i i i . i i i i i i i i -s | . . . . . . . . . . . . . . . . . . -p | p . p p p p p p p . p p p p p p p p -m | m . m m m m m m m . m m m m m m m m -d | d . d d d d d d d . d d d d d d d d -z | z . z z z z z z z . z z z z z z z z -n | n . n n n n n n n . n n n n n n n n -u | u . u u u u u u u . u u u u u u u u -v | v . v v v v v v v . v v v v v v v v -t | t . t t t t t t t . t t t t t t t t + | b g x h i j e f c s p m d z n u v t +-| ----------------------------------- +b| i . i i i i i i i . i i i i i i i i +g| . . . . . . . . . . . . . . . . . . +x| i . i i i i i i i . i i i i i i i i +h| i . i i i i i i i . i i i i i i i i +i| i . i i i i i i i . i i i i i i i i +j| j . j j j j j j j . j j j j j j j j +e| f . f f f f f f f . f f f f f f f f +f| f . f f f f f f f . f f f f f f f f +c| i . i i i i i i i . i i i i i i i i +s| . . . . . . . . . . . . . . . . . . +p| p . p p p p p p p . p p p p p p p p +m| m . m m m m m m m . m m m m m m m m +d| d . d d d d d d d . d d d d d d d d +z| z . z z z z z z z . z z z z z z z z +n| n . n n n n n n n . n n n n n n n n +u| u . u u u u u u u . u u u u u u u u +v| v . v v v v v v v . v v v v v v v v +t| t . t t t t t t t . t t t t t t t t ``` The possible range of output types are `dfijmnptuvz`. ---- -:fontawesome-solid-book: -[`%` Divide](divide.md), [`div`](div.md), [`reciprocal`](reciprocal.md) + +[`%` Divide](divide.md), [`div`](div.md), [`reciprocal`](reciprocal.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-solid-street-view: -_Q for Mortals_: [§4.8.1 Integer Division `div` and Modulus `mod`](/q4m3/4_Operators/#481-integer-division-div-and-modulus-mod) + +_Q for Mortals_: [§4.8.1 Integer Division `div` and Modulus `mod`](../learn/q4m/4_Operators.md/#481-integer-division-div-and-modulus-mod) diff --git a/docs/ref/divide.md b/docs/ref/divide.md index fee3f1db1..e20e9d24d 100644 --- a/docs/ref/divide.md +++ b/docs/ref/divide.md @@ -1,14 +1,10 @@ --- -title: Divide | Reference | kdb+ and q documentation +title: Divide | Reference | KDB-X and q documentation description: Divide is a q operator that returns the ratio of its arguments. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `%` Divide - - - - ```syntax x%y %[x;y] ``` @@ -45,12 +41,11 @@ q)2010.01.01 % 2005.01.01 1.999453 ``` -`%` is a [multithreaded primitive](../kb/mt-primitives.md). - +`%` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -Divide is an [atomic function](../basics/atomic.md). +Divide is an [atomic function](atomic.md). ```q q)(10;20 30)%(2;3 4) @@ -58,7 +53,7 @@ q)(10;20 30)%(2;3 4) 6.666667 7.5 ``` -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -87,11 +82,10 @@ def| 1 1 ghi| 1 1 ``` - ## Range and domains The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt b g x h i j e f c s p m d z n u v t @@ -119,14 +113,14 @@ t | f . f f f f f f f . f f f f f f f f Range: `f` ---- -:fontawesome-solid-book: + [`div`](div.md), [Multiply](multiply.md), [`ratios`](ratios.md)
-:fontawesome-solid-street-view: -[Mathematics](../basics/math.md) -
-:fontawesome-solid-book-open: + +[Mathematics](math.md) +
q4m + _Q for Mortals_ -[§4.4 Basic Arithmetic](/q4m3/4_Operators/#44-basic-arithmetic-) +[§4.4 Basic Arithmetic](../learn/q4m/4_Operators.md/#44-basic-arithmetic-) diff --git a/docs/ref/do.md b/docs/ref/do.md index e35f53574..26ebe7806 100644 --- a/docs/ref/do.md +++ b/docs/ref/do.md @@ -1,8 +1,8 @@ --- -title: do control word | Reference | kdb+ and q documentation +title: do control word | Reference | KDB-X and q documentation description: do is a q control word that evaluates one or more expressions a set number of times. -author: Stephen Taylor -keywords: control, evaluate, expression, kdb+, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: control, evaluate, expression, KDB-X, q --- # `do` @@ -44,14 +44,14 @@ The brackets of the expression list do not create lexical scope. Name scope within the brackets is the same as outside them. ---- -:fontawesome-solid-book: + [Accumulators – Do](accumulators.md#do), [`if`](if.md), [`while`](while.md)
-:fontawesome-solid-book-open: -[Controlling evaluation](../basics/control.md) + +[Controlling evaluation](control.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§10.1.5 `do`](/q4m3/10_Execution_Control/#1015-do) +[§10.1.6 `do`](../learn/q4m/10_Execution_Control.md#1016-do) diff --git a/docs/ref/doth.md b/docs/ref/doth.md index ad156755b..67f619bbe 100644 --- a/docs/ref/doth.md +++ b/docs/ref/doth.md @@ -1,16 +1,13 @@ --- -title: The .h namespace | Reference | kdb+ and q documentation +title: The .h namespace | Reference | KDB-X and q documentation description: The .h namespace contains objects useful for marking up data for an HTTP response. -author: Stephen Taylor -keywords: html, kdb+, markup, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: html, KDB-X, markup, q --- -# :fontawesome-brands-html5: The `.h` namespace - - +# The `.h` namespace _Markup tools_ -
Markup (HTML and XML) Data Serialization [`.h.br`](#hbr-linebreak) linebreak [`.h.cd`](#hcd-csv-from-data) CSV from data @@ -33,7 +30,7 @@ Markup (HTML and XML) Data Serialization [`.h.xs`](#hxs-xml-escape) XML escape [`.h.sb`](#hsb-body-style) body style [`.h.val`](#hval-value) value HTTP - [`.h.he`](#hhe-http-400) HTTP 400 URI formatting + [`.h.he`](#hhe-http-400) HTTP 400 URI formatting [`.h.hn`](#hhn-http-response) HTTP response [`.h.hu`](#hhu-uri-escape) URI escape [`.h.hp`](#hhp-http-response-pre) HTTP response pre [`.h.hug`](#hhug-uri-map) URI map [`.h.hy`](#hhy-http-response-content) HTTP response content [`.h.sc`](#hsc-uri-safe) URI-safe @@ -41,35 +38,29 @@ HTTP [`.h.ty`](#hty-mime-types) MIME types
-The `.h` [namespace](../basics/namespaces.md) contains objects for +The `.h` [namespace](namespaces.md) contains objects for -- marking up strings as HTML -- converting data into various formats -- composing HTTP responses -- web-console display +- marking up strings as HTML +- converting data into various formats +- composing HTTP responses +- web-console display !!! warning "The `.h` namespace is reserved for use by KX, as are all single-letter namespaces." Consider all undocumented functions in the namespace as its private API | and do not use them. - - - ## `.h.br` (linebreak) HTML linebreak (string), defaults to `"
"`. - ## `.h.c0` (web color) Color used by the web console (symbol), defaults to `` `024C7E``. - ## `.h.c1` (web color) Color used by the web console (symbol), defaults to `` `958600``. - ## `.h.cd` (CSV from data) ```syntax @@ -93,10 +84,8 @@ q).h.cd (`a`b`c;1 2 3;"xyz") Columns can be nested vectors, in which case [`.h.d`](#hd-delimiter) is used to separate subitems. (Since V4.0 2020.03.17.) -:fontawesome-regular-hand-point-right: [0: load csv](file-text.md#load-csv), [save](save.md#save) (save and format data) - ## `.h.code` (code after Tab) ```syntax @@ -105,8 +94,8 @@ Columns can be nested vectors, in which case [`.h.d`](#hd-delimiter) is used to Where `x` is a string with embedded Tab characters, returns the string with alternating segments marked up as -- plain text -- `code` and `nobr`. +- plain text +- `code` and `nobr`. ```q q).h.code "foo\tbar" @@ -117,7 +106,6 @@ q).h.code "foo" "foo" ``` - ## `.h.d` (delimiter) Delimiter used by [`.h.cd`](#hcd-csv-from-data) to join subitems of nested lists. Default is `" "`. @@ -146,7 +134,6 @@ q).h.cd t "2,a*b*c,1*2*3" ``` - ## `.h.ed` (Excel from data) ```syntax @@ -161,7 +148,6 @@ q).h.ed ([]a:1 2 3;b:`x`y`z) "" ``` - - ## `.h.ha` (anchor) ```syntax @@ -255,7 +238,6 @@ q).h.ha["http://www.example.com";"Example.com Main Page"] "Example.com Main Page" ``` - ## `.h.hb` (anchor target) ```syntax @@ -269,7 +251,6 @@ q).h.hb["http://www.example.com";"Example.com Main Page"] "Example.com Main Page" ``` - ## `.h.hc` (escape lt) ```syntax @@ -283,7 +264,6 @@ q).h.hc "" "<foo>" ``` - ## `.h.he` (HTTP 400) ```syntax @@ -297,7 +277,6 @@ q).h.he "" "HTTP/1.1 400 Bad Request\r\nContent-Type: text/plain\r\nConnection: close\r\.. ``` - ## `.h.hn` (HTTP response) ```syntax @@ -306,25 +285,27 @@ q).h.he "" Where -- `x` is the [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) (string) -- `y` is a [MIME type](#hty-mime-types) (symbol) corresponding to a key from the [`.h.ty`](#hty-mime-types) (MIME types) dictionary. If the type is not found in `h.ty` it defaults to populating the resulting MIME type with `application/octet-stream`. -- `z` is the content (string). Since 4.1 2025.11.25, a byte vector is also accepted. +- `x` is the [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) (string) +- `y` is a [MIME type](#hty-mime-types) (symbol) corresponding to a key from the [`.h.ty`](#hty-mime-types) (MIME types) dictionary. If the type is not found in `h.ty` it defaults to populating the resulting MIME type with `application/octet-stream`. +- `z` is the content (string). Since 4.1 2025.11.25, a byte vector is also accepted. returns as a string an HTTP error response. For example, a request for favicon.ico could be programmed to have a 'not found' response using the 404 HTTP code. + ```q q).h.hn["404";`txt;"Not found: favicon.ico"] "HTTP/1.1 404\r\nContent-Type: text/plain\r\nConnection: close\r\nContent-Length: 22\r\n\r\nNot found: favicon.ico" ``` + A request for the binary file 'test.exe' could generate a response using [read1](read1.md) to read the binary file before [casting](cast.md) the bytes to a string. An empty string is passed as a MIME type to `.h.hn` to allow it to default to `application/octet-stream`, which is appropriate for a binary file. + ```q q).h.hn["200";`;10h$read1`:test.exe] "HTTP/1.1 200\r\nContent-Type: application/octet-stream\r\nConnection: close\r\nContent-Length: 164\r\n\r\nPK\003\004\n\000\000\000\000\000\004^\005[\033\013\251;\010\000\000\000\010\000\000\000\003\000\034\000txtUT\t\000\003g\341\221h\203\341\221hux\013\000\001\004\365\001\000\000\004\000\000\000\000aaa bbb\nPK\001\002\036\003\n\000\000\000\000\000\004^\005[\033\013\251;\010\000\000\000\010\000\000\000\003\000\030\000\000\000\000\000\001\000\000\000\244\201\000\000\000\000txtUT\005\000\003g\341\221hux\013\000\001\004\365\001\000\000\004\000\000\000\000PK\005\006\000\000\000\000\001\000\001\000I\000\000\000E\000\000\000\000\000" ``` - ## `.h.hp` (HTTP response pre) ```syntax @@ -348,7 +329,6 @@ Content-Length: 257 ``` - ## `.h.hr` (horizontal rule) ```syntax @@ -356,12 +336,12 @@ Content-Length: 257 ``` Where `x` is a string, returns a string of the same length filled with `"-"`. + ```q q).h.hr "foo" "---" ``` - ## `.h.ht` (Marqdown to HTML) ```syntax @@ -385,7 +365,6 @@ Basic Marqdown formatting rules: - If second line of data starts with `"-"`, draw a horizontal rule to format the header - Aligns two-column data if 2nd column starts with `"\t "` - ## `.h.hta` (start tag) ```syntax @@ -399,7 +378,6 @@ q).h.hta[`a;(`href`target)!("http://www.example.com";"_blank")] "" ``` - ## `.h.htac` (element) ```syntax @@ -413,7 +391,6 @@ q).h.htac[`a;(`href`target)!("http://www.example.com";"_blank");"Example.com Mai "Example.com Main Pagevalue" ``` - ## `.h.html` (document) ```syntax @@ -454,7 +430,6 @@ q).h.html "

Hello world!

" " @@ -31,17 +32,17 @@ author: Stephen Taylor
### By category + --8<-- "docs/ref/kwdcat.txt"
-:fontawesome-solid-book: [`.Q.id`](dotq.md#id-sanitize) (sanitize), [`.Q.res`](dotq.md#res-keywords) (reserved words) - ## Operators + @@ -52,17 +53,17 @@ author: Stephen Taylor - + - + - + - + @@ -76,14 +77,12 @@ author: Stephen Taylor - +
[`$`](overloads.md#dollar)[Cast](cast.md), [Tok](tok.md), [Enumerate](enumerate.md), [Pad](pad.md), [`mmu`](mmu.md)
[`!`](overloads.md#bang)[Dict](dict.md), [Enkey](enkey.md), [Unkey](enkey.md#unkey), [Enumeration](enumeration.md), [Flip Splayed](flip-splayed.md), [Display](display.md), [internal](../basics/internal.md), [Update](../basics/funsql.md#update), [Delete](../basics/funsql.md#delete), [`lsq`](lsq.md)[`!`](overloads.md#bang)[Dict](dict.md), [Enkey](enkey.md), [Unkey](enkey.md#unkey), [Enumeration](enumeration.md), [Flip Splayed](flip-splayed.md), [Display](display.md), [internal](internal.md), [Update](funsql.md#update), [Delete](funsql.md#delete), [`lsq`](lsq.md)
[`?`](overloads.md#query)[Find](find.md), [Roll, Deal](deal.md), [Enum Extend](enum-extend.md), [Select](../basics/funsql.md#select), [Exec](../basics/funsql.md#exec), [Simple Exec](../basics/funsql.md#simple-exec), [Vector Conditional](vector-conditional.md)[`?`](overloads.md#query)[Find](find.md), [Roll, Deal](deal.md), [Enum Extend](enum-extend.md), [Select](funsql.md#select), [Exec](funsql.md#exec), [Simple Exec](funsql.md#simple-exec), [Vector Conditional](vector-conditional.md)
`+ - * %`[Add](add.md), [Subtract](subtract.md), [Multiply](multiply.md), [Divide](divide.md)
`= <> ~`[Equals](../basics/comparison.md#six-comparison-operators), [Not Equals](../basics/comparison.md#six-comparison-operators), [Match](../basics/comparison.md#match)
`= <> ~`[Equals](comparison.md#six-comparison-operators), [Not Equals](comparison.md#six-comparison-operators), [Match](comparison.md#match)
`< <= >= >`[Less Than](../basics/comparison.md#six-comparison-operators), [Up To](../basics/comparison.md#six-comparison-operators), [At Least](../basics/comparison.md#six-comparison-operators), [Greater Than](../basics/comparison.md#six-comparison-operators)`< <= >= >`[Less Than](comparison.md#six-comparison-operators), [Up To](comparison.md#six-comparison-operators), [At Least](comparison.md#six-comparison-operators), [Greater Than](comparison.md#six-comparison-operators)
`| &`[Greater (OR)](greater.md), [Lesser, AND](lesser.md)
[`'`](overloads.md#quote)[Compose](compose.md)
`0: 1: 2:`[File Text](file-text.md), [File Binary](file-binary.md), [Dynamic Load](dynamic-load.md)
`0 ±1 ±2 ±n`write to [console, stdout, stderr, handle _n_](../basics/handles.md)
`0 ±1 ±2 ±n`write to [console, stdout, stderr, handle _n_](handles.md)
`.: @: $: !: ?: +: -: *: %: =: ~: <: >: |: &: #: _: ^: ,:`[Assign through operator](assign.md#assign-through-operator)
-:fontawesome-solid-book: [Overloaded glyphs](overloads.md) - ## [Iterators](iterators.md)
@@ -93,77 +92,68 @@ author: Stephen Taylor [`':`](overloads.md#quote-colon) [Each Prior](maps.md#each-prior), [`prior`](prior.md)
-## [Execution control](../basics/control.md) +## [Execution control](control.md)
-[.[f;x;e] Trap](../ref/apply.md#trap) [: Return](../basics/function-notation.md#explicit-return) [do](../ref/do.md) [exit](../ref/exit.md) [\$[x;y;z] Cond](../ref/cond.md) -[@[f;x;e] Trap-At](../ref/apply.md#trap) [' Signal](../ref/signal.md) [if](../ref/if.md) [while](../ref/while.md) [:[v;p1;r1;...] Pattern conditional](../basics/pattern.md#pattern-conditional) +[.[f;x;e] Trap](apply.md#trap) [: Return](function-notation.md#explicit-return) [do](do.md) [exit](exit.md) [\$[x;y;z] Cond](cond.md) +[@[f;x;e] Trap-At](apply.md#trap) [' Signal](signal.md) [if](if.md) [while](while.md) [:[v;p1;r1;...] Pattern conditional](pattern.md#pattern-conditional)
-:fontawesome-solid-book-open: -[Debugging](../basics/debug.md) - - +[Debugging](../how_to/working-with-code/debug.md) ## Other
-[` pop stack](../basics/debug.md#debugging) [::](overloads.md#colon-colon) [identity](identity.md) [\x system cmd x](../basics/syscmds.md) -[.](overloads.md#dot) [push stack](../basics/debug.md#debugging) [generic null](identity.md) [\\ abort](../basics/debug.md#abort) - [global amend](../basics/function-notation.md#name-scope) \\\\ quit q - [set view](../learn/views.md) / comment - -() [precedence](../basics/syntax.md#precedence-and-order-of-evaluation) \[;\] [expn block](../basics/syntax.md#conditional-evaluation-and-control-statements) {} [lambda](../basics/function-notation.md) \` symbol -(;) [list](../basics/syntax.md#list-notation) [argt list](../basics/syntax.md#bracket-notation) ; separator \`: filepath -(\[\]..) [table](../basics/syntax.md#table-notation) +[` pop stack](../how_to/working-with-code/debug.md) [::](overloads.md#colon-colon) [identity](identity.md) [\x system cmd x](syscmds.md) +[.](overloads.md#dot) [push stack](../how_to/working-with-code/debug.md) [generic null](identity.md) [\\ abort](../how_to/working-with-code/debug.md) + [global amend](function-notation.md#name-scope) \\\\ quit q + [set view](https://code.kx.com/q/learn/views/) / comment + +() [precedence](syntax.md#precedence-and-order-of-evaluation) \[;\] [expn block](syntax.md#conditional-evaluation-and-control-statements) {} [lambda](function-notation.md) \` symbol +(;) [list](syntax.md#list-notation) [argt list](syntax.md#bracket-notation) ; separator \`: filepath +(\[\]..) [table](syntax.md#table-notation)
+ - - - -## [Attributes](../basics/syntax.md#attributes) +## [Attributes](syntax.md#attributes)
**g** grouped **p** parted **s** sorted **u** unique
-:fontawesome-solid-book: [Set Attribute](set-attribute.md) - ## Command-line options and system commands - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +
[file](../basics/cmdline.md#file)
[`\a`](../basics/syscmds.md#a-tables)tables[`\r`](../basics/syscmds.md#r-rename)rename
[`-b`](../basics/cmdline.md#-b-blocked)blocked[`-s`](../basics/cmdline.md#-s-secondary-threads) [`\s`](../basics/syscmds.md#s-number-of-secondary-threads)secondary processes
[`\b`](../basics/syscmds.md#b-views) [`\B`](../basics/syscmds.md#b-pending-views)views[`-S`](../basics/cmdline.md#-s-random-seed) [`\S`](../basics/syscmds.md#s-random-seed)random seed
[`-c`](../basics/cmdline.md#-c-console-size) [`\c`](../basics/syscmds.md#c-console-size)console size[`-t`](../basics/cmdline.md#-t-timer-ticks) [`\t`](../basics/syscmds.md#t-timer)timer ticks
[`-C`](../basics/cmdline.md#-c-http-size) [`\C`](../basics/syscmds.md#c-http-size)HTTP size[`\ts`](../basics/syscmds.md#ts-time-and-space)time and space
[`\cd`](../basics/syscmds.md#cd-change-directory)change directory[`-T`](../basics/cmdline.md#-t-timeout) [`\T`](../basics/syscmds.md#t-timeout)timeout
[`\d`](../basics/syscmds.md#d-directory)directory[`-u`](../basics/cmdline.md#-u-usr-pwd-local) [`-U`](../basics/cmdline.md#-u-usr-pwd) [`\u`](../basics/syscmds.md#u-reload-user-password-file)usr-pwd
[`-e`](../basics/cmdline.md#-e-error-traps) [`\e`](../basics/syscmds.md#e-error-trap-clients)error traps[`-u`](../basics/cmdline.md#-u-disable-syscmds)disable syscmds
[`-E`](../basics/cmdline.md#-e-tls-server-mode) [`\E`](../basics/syscmds.md#e-tls-server-mode)TLS server mode[`\v`](../basics/syscmds.md#v-variables)variables
[`\f`](../basics/syscmds.md#f-functions)functions[`-w`](../basics/cmdline.md#-w-workspace) [`\w`](../basics/syscmds.md#w-workspace)memory
[`-g`](../basics/cmdline.md#-g-garbage-collection) [`\g`](../basics/syscmds.md#g-garbage-collection-mode)garbage collection[`-W`](../basics/cmdline.md#-w-start-week) [`\W`](../basics/syscmds.md#w-week-offset)week offset
[`\l`](../basics/syscmds.md#l-load-file-or-directory)load file or directory[`\x`](../basics/syscmds.md#x-expunge)expunge
[`-l`](../basics/cmdline.md#-l-log-updates) [`-L`](../basics/cmdline.md#-l-log-sync)log sync[`-z`](../basics/cmdline.md#-z-date-format) [`\z`](../basics/syscmds.md#z-date-parsing)date format
[`-o`](../basics/cmdline.md#-o-utc-offset) [`\o`](../basics/syscmds.md#o-offset-from-utc)UTC offset[`\1` `\2`](../basics/syscmds.md#1-2-redirect)redirect
[`-p`](../basics/cmdline.md#-p-listening-port) [`\p`](../basics/syscmds.md#p-listening-port)listening port[`\_`](../basics/syscmds.md#_-hide-q-code)hide q code
[`-P`](../basics/cmdline.md#-p-display-precision) [`\P`](../basics/syscmds.md#p-precision)display precision[`\`](../basics/syscmds.md#terminate)terminate
[`-q`](../basics/cmdline.md#-q-quiet-mode)quiet mode[`\`](../basics/syscmds.md#toggle-qk)toggle q/k
[`-r`](../basics/cmdline.md#-r-replicate) [`\r`](../basics/syscmds.md#r-replication-primary)replicate[`\\`](../basics/syscmds.md#quit)quit
[file](cmdline.md#file)
[`\a`](syscmds.md#a-tables)tables[`\r`](syscmds.md#r-rename)rename
[`-b`](cmdline.md#-b-blocked)blocked[`-s`](cmdline.md#-s-secondary-threads) [`\s`](syscmds.md#s-number-of-secondary-threads)secondary processes
[`\b`](syscmds.md#b-views) [`\B`](syscmds.md#b-pending-views)views[`-S`](cmdline.md#-s-random-seed) [`\S`](syscmds.md#s-random-seed)random seed
[`-c`](cmdline.md#-c-console-size) [`\c`](syscmds.md#c-console-size)console size[`-t`](cmdline.md#-t-timer-ticks) [`\t`](syscmds.md#t-timer)timer ticks
[`-C`](cmdline.md#-c-http-size) [`\C`](syscmds.md#c-http-size)HTTP size[`\ts`](syscmds.md#ts-time-and-space)time and space
[`\cd`](syscmds.md#cd-change-directory)change directory[`-T`](cmdline.md#-t-timeout) [`\T`](syscmds.md#t-timeout)timeout
[`\d`](syscmds.md#d-directory)directory[`-u`](cmdline.md#-u-usr-pwd-local) [`-U`](cmdline.md#-u-usr-pwd) [`\u`](syscmds.md#u-reload-user-password-file)usr-pwd
[`-e`](cmdline.md#-e-error-traps) [`\e`](syscmds.md#e-error-trap-clients)error traps[`-u`](cmdline.md#-u-disable-syscmds)disable syscmds
[`-E`](cmdline.md#-e-tls-server-mode) [`\E`](syscmds.md#e-tls-server-mode)TLS server mode[`\v`](syscmds.md#v-variables)variables
[`\f`](syscmds.md#f-functions)functions[`-w`](cmdline.md#-w-workspace) [`\w`](syscmds.md#w-workspace)memory
[`-g`](cmdline.md#-g-garbage-collection) [`\g`](syscmds.md#g-garbage-collection-mode)garbage collection[`-W`](cmdline.md#-w-start-week) [`\W`](syscmds.md#w-week-offset)week offset
[`\l`](syscmds.md#l-load-file-or-directory)load file or directory[`\x`](syscmds.md#x-expunge)expunge
[`-l`](cmdline.md#-l-log-updates) [`-L`](cmdline.md#-l-log-sync)log sync[`-z`](cmdline.md#-z-date-format) [`\z`](syscmds.md#z-date-parsing)date format
[`-o`](cmdline.md#-o-utc-offset) [`\o`](syscmds.md#o-offset-from-utc)UTC offset[`\1` `\2`](syscmds.md#1-2-redirect)redirect
[`-p`](cmdline.md#-p-listening-port) [`\p`](syscmds.md#p-listening-port)listening port[`\_`](syscmds.md#_-hide-q-code)hide q code
[`-P`](cmdline.md#-p-display-precision) [`\P`](syscmds.md#p-precision)display precision[`\`](syscmds.md#terminate)terminate
[`-q`](cmdline.md#-q-quiet-mode)quiet mode[`\`](syscmds.md#toggle-qk)toggle q/k
[`-r`](cmdline.md#-r-replicate) [`\r`](syscmds.md#r-replication-primary)replicate[`\\`](syscmds.md#quit)quit
-:fontawesome-solid-book: -[`system`](../ref/system.md) +[`system`](system.md)
-:fontawesome-solid-book-open: -[Command-line options](../basics/cmdline.md), -[System commands](../basics/syscmds.md), -[OS commands](../basics/syscmds.md#os-commands) +[Command-line options](cmdline.md), +[System commands](syscmds.md), +[OS commands](syscmds.md#os-commands) -## [Datatypes](../basics/datatypes.md) +## [Datatypes](datatypes.md)
**Basic datatypes** @@ -230,18 +220,18 @@ RO: read only; RW: read-write **Other datatypes** 20-76 enums -77 anymap 104 [projection](../basics/application.md#projection) +77 anymap 104 [projection](application.md#projection) 78-96 77+t – mapped list of lists of type t 105 [composition](compose.md) 97 nested sym enum 106 [f'](maps.md#each) 98 table 107 [f/](accumulators.md) 99 dictionary 108 [f\\](accumulators.md) -100 [lambda](../basics/function-notation.md) 109 [f':](maps.md) +100 [lambda](function-notation.md) 109 [f':](maps.md) 101 unary primitive 110 [f/:](maps.md#each-left-and-each-right) 102 operator 111 [f\\:](maps.md#each-left-and-each-right) 103 [iterator](iterators.md) 112 [dynamic load](dynamic-load.md)
-Above, `f` is an [applicable value](../basics/glossary.md#applicable-value). +Above, `f` is an [applicable value](glossary.md#applicable-value). Nested types are 77+t (e.g. 78 is boolean. 96 is time.) @@ -255,7 +245,6 @@ time.(minute second mm ss) milliseconds: time mod 1000 ``` - ## Namespaces ### [`.h`](doth.md) (markup) @@ -266,9 +255,9 @@ HTTP, markup and data conversion. De/serialize as JSON. -### [`.m`](dotm.md) (memory backed files) +### [`.m`](dotm.md) (modules) -Memory backed by files. +The currently loaded modules. The meaning of `.m` has changed between kdb+ versions. ### [`.Q`](dotq.md) (utils) @@ -277,4 +266,3 @@ Utilities: general, environment, IPC, datatype, database, partitioned database s ### [`.z`](dotz.md) (environment, callbacks) Environment, callbacks - diff --git a/docs/ref/insert.md b/docs/ref/insert.md index 5fb6e002d..6e5e9afb4 100644 --- a/docs/ref/insert.md +++ b/docs/ref/insert.md @@ -1,7 +1,7 @@ --- -title: insert keyword | Reference | kdb+ and q documentation +title: insert keyword | Reference | KDB-X and q documentation description: insert is a q keyword that inserts or appends records to a table. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `insert` @@ -77,7 +77,7 @@ t| 50 !!! tip "`insert` can insert to global variables only." - If you need to insert to function-local tables, use [`x,:y`](assign.md#assign-through-operator) or [Update](../basics/funsql.md#update) instead. + If you need to insert to function-local tables, use [`x,:y`](assign.md#assign-through-operator) or [Update](funsql.md#update) instead. ## Type @@ -119,19 +119,19 @@ type y value wrong type !!! tip "With keyed tables, consider [`upsert`](upsert.md) as an alternative." ---- -:fontawesome-solid-book: + [Join](join.md)
-:fontawesome-solid-book: + [`upsert`](upsert.md)
-:fontawesome-solid-book-open: -[Functional qSQL](../basics/funsql.md) + +[Functional qSQL](funsql.md)
-:fontawesome-solid-book-open: -[qSQL query templates](../basics/qsql.md) + +[qSQL query templates](qsql.md)
-:fontawesome-solid-book-open: -[Tables](../kb/faq.md) + +[Tables](faq.md) diff --git a/docs/ref/inter.md b/docs/ref/inter.md index 7586e206d..5fb30127a 100644 --- a/docs/ref/inter.md +++ b/docs/ref/inter.md @@ -1,8 +1,8 @@ --- -title: inter – Reference – kdb+ and q documentation +title: inter – Reference – KDB-X and q documentation description: inter is a q keyword that returns the intersection of two lists or dictionaries. -author: Stephen Taylor -keywords: inter, intersection, kdb+, q, select +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: inter, intersection, KDB-X, q, select --- # `inter` @@ -65,8 +65,8 @@ t 40 ``` --- -:fontawesome-solid-book: + [`in`](in.md), [`within`](within.md)
-:fontawesome-solid-book-open: -[Selection](../basics/by-topic.md#selection) + +[Selection](by-topic.md#selection) diff --git a/docs/ref/inv.md b/docs/ref/inv.md index 1da151f51..2bcbe0d61 100644 --- a/docs/ref/inv.md +++ b/docs/ref/inv.md @@ -1,7 +1,7 @@ --- -title: inv – matrix inverse | Reference | kdb+ and q documentation +title: inv – matrix inverse | Reference | KDB-X and q documentation description: inv is a q keyword that returns the matrix inverse of its argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `inv` @@ -39,12 +39,12 @@ Previously it used Cholesky decomposition as well. ---- -:fontawesome-solid-book: + [`lsq`](lsq.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-brands-wikipedia-w: + [LU decomposition](https://en.wikipedia.org/wiki/LU_decomposition "Wikipedia"), [Cholesky decomposition](https://en.wikipedia.org/wiki/Cholesky_decomposition#Matrix_inversion "Wikipedia") \ No newline at end of file diff --git a/docs/ref/iterators.md b/docs/ref/iterators.md index 0309d1715..35de1cdd2 100644 --- a/docs/ref/iterators.md +++ b/docs/ref/iterators.md @@ -1,8 +1,8 @@ --- -title: Iterators | Reference | kdb+ and q documentation +title: Iterators | Reference | KDB-X and q documentation description: The iterators (earlier known as adverbs) are native higher-order operators. They take applicable values as arguments and return derived functions. date: March 2019 -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # Iterators @@ -17,14 +17,14 @@ author: Stephen Taylor [' Case](maps.md#case) -The iterators (once known as _adverbs_) are native higher-order operators: they take [applicable values](../basics/glossary.md#applicable-value) as arguments and return derived functions. +The iterators (once known as _adverbs_) are native higher-order operators: they take [applicable values](glossary.md#applicable-value) as arguments and return derived functions. They are the primary means of iterating in q. -:fontawesome-solid-book-open: -[Iteration](../basics/iteration.md) in q + +[Iteration](iteration.md) in q
-:fontawesome-regular-map: -[Iterators](../wp/iterators/index.md) + +[Iterators](iterators.md) !!! detail "Applicable value" @@ -56,8 +56,8 @@ q)+/[1000000;2 3 4] / binary 1000009 ``` -:fontawesome-solid-book-open: -[Variadic syntax](../basics/variadic.md) + +[Variadic syntax](variadic.md) ## Postfix application @@ -91,7 +91,7 @@ q)count'[txt] / unary function applied with brackets 3 5 5 4 ``` -If the derived function is unary or [variadic](../basics/variadic.md), you can also parenthesize it and apply it prefix. +If the derived function is unary or [variadic](variadic.md), you can also parenthesize it and apply it prefix. ```q q)(count')txt / unary function applied prefix diff --git a/docs/ref/join.md b/docs/ref/join.md index 57f889d83..7ae3ff1d3 100644 --- a/docs/ref/join.md +++ b/docs/ref/join.md @@ -1,7 +1,7 @@ --- -title: Join atoms, lists, dictionaries or tables | Reference | kdb+ and q documentation +title: Join atoms, lists, dictionaries or tables | Reference | KDB-X and q documentation description: Join is a q operator that joins atoms, lists, dictionaries or tables. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `,` `,:` Join and Append ## `,` Join @@ -78,7 +78,7 @@ q)`a`b,`sym2$`c `a`b`c ``` -`,`(join) is a [multithreaded primitive](../kb/mt-primitives.md). +`,`(join) is a [multithreaded primitive](mt-primitives.md). ### Dictionaries @@ -111,10 +111,10 @@ a b 11 e ``` -:fontawesome-solid-book: + [`uj`](uj.md) union join
-:fontawesome-solid-globe: + [SQL UNION ALL](https://www.w3schools.com/sql/sql_union.asp) Tables of the same count can be joined column-wise with `,'` (Join Each). @@ -278,10 +278,10 @@ f| 12 ---- -:fontawesome-solid-book: + [`.Q.dd`](dotq.md#dd-join-symbols) join symbols
-:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md) diff --git a/docs/ref/key.md b/docs/ref/key.md index da5198458..4975156f6 100644 --- a/docs/ref/key.md +++ b/docs/ref/key.md @@ -1,8 +1,8 @@ --- -title: key keyword | Reference | kdb+ and q documentation +title: key keyword | Reference | KDB-X and q documentation description: Keys of a dictionary; key columns of a keyed table; files in a folder; whether a file or name exists; target of a foreign key, type of a vector; or the enumerator of a list. -author: Stephen Taylor -keywords: dictionary, directory, enumeration, file, foreign key, handle, kdb+, keyed table, q, symbol, til, vector +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: dictionary, directory, enumeration, file, foreign key, handle, KDB-X, keyed table, q, symbol, til, vector --- # `key` @@ -56,10 +56,10 @@ w e ``` -:fontawesome-solid-book: + [`keys`, `xkey`](keys.md)
-:fontawesome-solid-book: + [`!` Enkey, Unkey](enkey.md) @@ -157,7 +157,7 @@ q)key x ## Type of a vector -Where `x` is a vector returns the name of its [type](../basics/datatypes.md) as a symbol. +Where `x` is a vector returns the name of its [type](datatypes.md) as a symbol. ```q q)key each ("abc";101b;1 2 3h;1 2 3;1 2 3;1 2 3f) @@ -190,6 +190,6 @@ q)key 10 ---- -:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) + +[Metadata](metadata.md) diff --git a/docs/ref/keys.md b/docs/ref/keys.md index 85f98b12c..2c76ba5f4 100644 --- a/docs/ref/keys.md +++ b/docs/ref/keys.md @@ -1,8 +1,8 @@ --- -title: keys, xkey – Reference – kdb+ and q documentation +title: keys, xkey – Reference – KDB-X and q documentation description: keys and xkey are q keywords that get or set the key columns of a table. author: Stephen taylor -keyword: kdb+, key, key columns, keyed table, q +keyword: KDB-X, key, key columns, keyed table, q --- # `keys`, `xkey` @@ -66,13 +66,13 @@ q)keys trade / sym is now primary key of trade ``` --- -:fontawesome-solid-book: + [Enkey, Unkey](enkey.md)
-:fontawesome-solid-book: + [`.Q.ff`](dotq.md#ff-append-columns) (append columns)
-:fontawesome-solid-book-open: -[Dictionaries](../basics/dictsandtables.md), -[Tables](../kb/faq.md), -[Metadata](../basics/metadata.md) \ No newline at end of file + +[Dictionaries](dictsandtables.md), +[Tables](faq.md), +[Metadata](metadata.md) \ No newline at end of file diff --git a/docs/ref/less-than.md b/docs/ref/less-than.md index ae7683ac8..0f92dffcf 100644 --- a/docs/ref/less-than.md +++ b/docs/ref/less-than.md @@ -1,13 +1,11 @@ --- -title: Less Than, Up To – Reference – kdb+ and q documentation +title: Less Than, Up To – Reference – KDB-X and q documentation description: Less Than and Up To are q operators that compare the values of their arguments. -author: Stephen Taylor -keywords: comparison, kdb+, less-than, less-than-or-equal, q, up to +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: comparison, KDB-X, less-than, less-than-or-equal, q, up to --- # `<` Less Than
`<=` Up To - - ```syntax x -:fontawesome-solid-book-open: -[Comparison](../basics/comparison.md) + +[Comparison](comparison.md) diff --git a/docs/ref/lesser.md b/docs/ref/lesser.md index e8acbc556..c7b13bf05 100644 --- a/docs/ref/lesser.md +++ b/docs/ref/lesser.md @@ -1,13 +1,10 @@ --- -title: Lesser, and | Reference | kdb+ and q documentation +title: Lesser, and | Reference | KDB-X and q documentation description: Lesser is a q operator that returns the lesser of its arguments. and is a q keyword that performs a logical AND. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `&` Lesser, `and` - - - _Lesser of two values; logical AND_ ```syntax @@ -15,7 +12,7 @@ x & y &[x;y] x and y and[x;y] ``` -Returns the [lesser](../basics/comparison.md) of the underlying values of `x` and `y`. +Returns the [lesser](comparison.md) of the underlying values of `x` and `y`. ```q q)2&3 @@ -26,12 +23,11 @@ q)"sat"&"cow" "cat" ``` -`&` is a [multithreaded primitive](../kb/mt-primitives.md). - +`&` is a [multithreaded primitive](mt-primitives.md). ## Flags -Where `x` and `y` are both [flags](../basics/glossary.md#flag), Lesser is logical AND. +Where `x` and `y` are both [flags](glossary.md#flag), Lesser is logical AND. !!! tip "Use `and` for flags" @@ -39,7 +35,6 @@ Where `x` and `y` are both [flags](../basics/glossary.md#flag), Lesser is logica There is no performance implication. - ## Dictionaries and keyed tables Where `x` and `y` are a pair of dictionaries or keyed tables their minimum is equivalent to upserting `y` into `x` where the values of `y` are less than those in `x`. @@ -68,7 +63,6 @@ appl | 2015.03 goog | 2017.11 ``` - ## Mixed types Where `x` and `y` are of different types the lesser of their underlying values is returned as the higher of the two types. @@ -78,10 +72,9 @@ q)98&"c" "b" ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -Lesser and `and` are [atomic functions](../basics/atomic.md). +Lesser and `and` are [atomic functions](atomic.md). ```q q)(10;20 30)&(2;3 4) @@ -89,7 +82,7 @@ q)(10;20 30)&(2;3 4) 3 4 ``` -They apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +They apply to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -118,13 +111,10 @@ def| -21 5 ghi| 3 -6 ``` - - - ## Domain and range The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt b g x h i j e f c s p m d z n u v t @@ -152,16 +142,14 @@ t | t . t t t t t t t . t . . t n t t t The possible range of output types are `bcdefhijmnptuvxz`. ---- -:fontawesome-solid-book: + [`or`, `|`, Greater](greater.md), [`max`](max.md), [`min`](min.md)
-:fontawesome-solid-book-open: -[Comparison](../basics/comparison.md), -[Logic](../basics/by-topic.md#logic) -
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§4.5 Greater and Lesser](/q4m3/4_Operators/#45-greater-and-lesser-amp) +[Comparison](comparison.md), +[Logic](by-topic.md#logic) +
+_Q for Mortals_ +[§4.5 Greater and Lesser](../learn/q4m/4_Operators.md#45-greater-and-lesser) diff --git a/docs/ref/like.md b/docs/ref/like.md index 777a708e4..0f2cf1259 100644 --- a/docs/ref/like.md +++ b/docs/ref/like.md @@ -1,21 +1,20 @@ --- -title: like – matches patterns | Reference | kdb+ and q documentation +title: like – matches patterns | Reference | KDB-X and q documentation description: like is a q keyword that matches text to a pattern. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `like` - _Whether text matches a pattern_ ```syntax x like y like[x;y] ``` -Where +Where -- `x` is a symbol or string -- `y` is a pattern as a string +- `x` is a symbol or string +- `y` is a pattern as a string returns a boolean: whether `x` matches the pattern of `y`. @@ -28,7 +27,7 @@ q)`quickly like "quick*" 1b ``` -Absent [pattern characters](../basics/regex.md) in `y`, `like` is equivalent to `{y~string x}`. +Absent [pattern characters](regex.md) in `y`, `like` is equivalent to `{y~string x}`. ```q q)`quick like "quick" @@ -37,8 +36,7 @@ q)`quick like "quickish" 0b ``` - -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration `like` applies to lists of strings or symbols; and to dictionaries with them as values. @@ -52,17 +50,13 @@ b| 1 c| 0 ``` - - ---- -:fontawesome-solid-book: + [`ss`, `ssr`](ss.md),
-:fontawesome-solid-book-open: -[Regular expressions in q](../basics/regex.md), -[Strings](../basics/by-topic.md#strings) -
-:fontawesome-solid-graduation-cap: -[Using regular expressions](../basics/regex.md) +[Regular expressions in q](regex.md), +[Strings](by-topic.md#strings) +
+[Using regular expressions](regex.md) diff --git a/docs/ref/lj.md b/docs/ref/lj.md index 69dbb0f9b..a8e76d707 100644 --- a/docs/ref/lj.md +++ b/docs/ref/lj.md @@ -1,7 +1,7 @@ --- -title: lj – left join keyword | Reference | kdb+ and q documentation +title: lj – left join keyword | Reference | KDB-X and q documentation description: lj is a q keyword that performs a left join. -keywords: join, kdb+, left, left join, lj, ljf, q +keywords: join, KDB-X, left, left join, lj, ljf, q --- # `lj`, `ljf` @@ -59,7 +59,7 @@ c d 2 20 ``` -`lj` is a [multithreaded primitive](../kb/mt-primitives.md). +`lj` is a [multithreaded primitive](mt-primitives.md). ## Changes in V4.0 @@ -114,12 +114,12 @@ q)x lj y -| --- 1| 1 2| z - q)x lj y / kdb+ 3.0 + q)x lj y / q 3.0 a b c ----- 1 1 2 z - q)x lj y / kdb+ 2.8 + q)x lj y / q 2.8 a b c ------ 1 x 1 @@ -130,10 +130,10 @@ q)x lj y ---- -:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.9.2 Ad Hoc Left Join](/q4m3/9_Queries_q-sql/#992-ad-hoc-left-join-lj) +[§9.9.2 Ad Hoc Left Join](../learn/q4m/9_Queries_q-sql.md/#992-ad-hoc-left-join-lj) diff --git a/docs/ref/load.md b/docs/ref/load.md index 1b9b994f4..c34a69897 100644 --- a/docs/ref/load.md +++ b/docs/ref/load.md @@ -1,15 +1,12 @@ --- -title: load a table | Reference | kdb+ and q documentation +title: load a table | Reference | KDB-X and q documentation description: load is q keyword that loads binary data from a file or directory. -keywords: directory, file, kdb+, load, q, rload, splayed, table +keywords: directory, file, KDB-X, load, q, rload, splayed, table --- -# :fontawesome-solid-database: `load`, `rload` +# `load`, `rload` _Load binary data from a file or directory_ - - - ## `load` _Load binary data from a file_ @@ -18,17 +15,16 @@ _Load binary data from a file_ load x load[x] ``` -Where `x` is +Where `x` is -- a symbol atom or vector matching the name/s of datafile/s (with no extension) in the current directory, reads the datafile/s and assigns the value/s to global variable/s of the same name, which it returns -- a filesymbol atom or vector for datafile/s (with no extension), reads the datafile/s and assigns the value/s to global variable/s of the same name, which it returns -- a filesymbol for a directory, creates a global dictionary of the same name and within that dictionary recurses on any datafiles the directory contains +- a symbol atom or vector matching the name/s of datafile/s (with no extension) in the current directory, reads the datafile/s and assigns the value/s to global variable/s of the same name, which it returns +- a filesymbol atom or vector for datafile/s (with no extension), reads the datafile/s and assigns the value/s to global variable/s of the same name, which it returns +- a filesymbol for a directory, creates a global dictionary of the same name and within that dictionary recurses on any datafiles the directory contains -!!! tip "Signals a `type` error if the file is not a kdb+ data file" +!!! tip "Signals a `type` error if the file is not a KDB-X data file" There are no text formats corresponding to [` save`](save.md). Instead, use [File Text](file-text.md). - ```q q)t:([]x: 1 2 3; y: 10 20 30) q)save`t / save to a binary file (same as `:t set t) @@ -49,6 +45,7 @@ x y ``` The following example uses the tables created using the script [`sp.q`](https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q) + ```q q)\l sp.q q)\mkdir -p cb @@ -74,7 +71,6 @@ s5| adams 30 athens !!! warning "Operating systems may create hidden files, such as `.DS_Store`, that block `load`." - ## `rload` _Load a splayed table from a directory_ @@ -83,11 +79,12 @@ _Load a splayed table from a directory_ rload x rload[x] ``` -Where `x` is the table name as a symbol, the table is read from a directory of the same name. `rload` is the converse of [`rsave`](save.md#rsave). +Where `x` is the table name as a symbol, the table is read from a directory of the same name. `rload` is the converse of [`rsave`](save.md#rsave). !!! tip "The usual, and more general, way of doing this is to use [`get`](get.md), which allows a table to be defined with a different name than the source directory." The following example uses the table `sp` created using the script [`sp.q`](https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q) + ```q q)\l sp.q q)rsave `sp / save splayed table @@ -108,18 +105,17 @@ q)sp:get `:sp/ / equivalent to rload `sp ``` ---- -:fontawesome-solid-book: + [`save`, `rsave`](save.md) -[`.Q.dsftg`](dotq.md#dsftg-load-process-save) (load process save), -[`.Q.fps`](dotq.md#fps-pipe-streaming) (pipe streaming), -[`.Q.fs`](dotq.md#fs-file-streaming) (file streaming), -[`.Q.fsn`](dotq.md#fsn-file-streaming) (file streaming with chunks), +[`.Q.dsftg`](dotq.md#dsftg-load-process-save) (load process save), +[`.Q.fps`](dotq.md#fps-pipe-streaming) (pipe streaming), +[`.Q.fs`](dotq.md#fs-file-streaming) (file streaming), +[`.Q.fsn`](dotq.md#fsn-file-streaming) (file streaming with chunks), [`.Q.v`](dotq.md#v-value) (get splayed table)
-:fontawesome-solid-book-open: -[File system](../basics/files.md) + +[File system](files.md)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§11.2 Save and Load on Tables](/q4m3/11_IO/#112-save-and-load-on-tables) +_Q for Mortals_ +[§11.2 Save and Load on Tables](../learn/q4m/11_IO.md/#112-save-and-load-on-tables) diff --git a/docs/ref/log.md b/docs/ref/log.md index c1bc384c2..df51b55f4 100644 --- a/docs/ref/log.md +++ b/docs/ref/log.md @@ -1,14 +1,12 @@ --- -title: log, xlog – logarithms | Reference | kdb+ and q documentation +title: log, xlog – logarithms | Reference | KDB-X and q documentation description: log and xlog are q keywords that return logarithms, either natural or to a specified base. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `log`, `xlog` _Logarithms and natural logarithms_ - - ## `log` _Natural logarithm_ @@ -17,12 +15,12 @@ _Natural logarithm_ log x log[x] ``` -Where `x` is numeric and +Where `x` is numeric and -- null, returns null -- 0, returns `-0w` -- a datetime, returns `x` -- otherwise, the natural logarithm of `x` +- null, returns null +- 0, returns `-0w` +- a datetime, returns `x` +- otherwise, the natural logarithm of `x` ```q q)log 1 @@ -35,13 +33,12 @@ q)log -2 0n 0 0.1 1 42 0n 0n -0w -2.302585 0 3.73767 ``` -`log` is a [multithreaded primitive](../kb/mt-primitives.md). - +`log` is a [multithreaded primitive](mt-primitives.md). -### :fontawesome-solid-sitemap: Implicit iteration +### Implicit iteration -`log` is an [atomic function](../basics/atomic.md). -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables) +`log` is an [atomic function](atomic.md). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables) ```q q)log(2;3 4) @@ -69,7 +66,6 @@ def| 1.609438 ghi| 1.098612 ``` - ### Domain and range ```txt @@ -79,9 +75,8 @@ range f . f f f f f f f . f f f z f f f f Range: `fz` - - ---- + ## `xlog` _Logarithm_ @@ -112,13 +107,12 @@ q)"A"xlog"C" 1.00726 ``` -`xlog` is a [multithreaded primitive](../kb/mt-primitives.md). - +`xlog` is a [multithreaded primitive](mt-primitives.md). -### :fontawesome-solid-sitemap: Implicit iteration +### Implicit iteration -`xlog` is an [atomic function](../basics/atomic.md). -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables) +`xlog` is an [atomic function](atomic.md). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables) ```q q)(2;3 4)xlog(4;5 6) @@ -144,7 +138,6 @@ def| 0.69897 ghi| 0.4771213 ``` - ### `xlog` and `xexp` `xlog` is the inverse of `xexp`, i.e. `y~x xexp x xlog y`. @@ -154,7 +147,6 @@ q)2 xexp 2 xlog -1 0 0.125 1 42 0n 0 0.125 1 42 ``` - ### Domain and range ```txt @@ -183,9 +175,8 @@ t | f . f f f f f f f . f f f . f f f f Range: `f` ---- -:fontawesome-solid-book: + [`exp`, `xexp`](exp.md)
-:fontawesome-solid-book-open: -[Datatypes](../basics/datatypes.md) +[Datatypes](datatypes.md) diff --git a/docs/ref/lower.md b/docs/ref/lower.md index 1a9cb1c27..8687566d5 100644 --- a/docs/ref/lower.md +++ b/docs/ref/lower.md @@ -1,14 +1,12 @@ --- -title: Shift to lower or upper case | Reference | kdb+ and q documentation +title: Shift to lower or upper case | Reference | KDB-X and q documentation description: lower and upper are q keywords that shift text to lower or upper case respectively. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `lower`, `upper` _Shift case_ - - ```syntax lower x lower[x] upper x upper[x] @@ -16,7 +14,6 @@ upper x upper[x] Where `x` is a character or symbol atom or vector, returns it with any bicameral characters in the lower/upper case. - ```q q)lower"IBM" "ibm" @@ -29,9 +26,9 @@ q)upper`ibm`msft `IBM`MSFT ``` -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`lower` and `upper` are [atomic functions](../basics/atomic.md). +`lower` and `upper` are [atomic functions](atomic.md). ```q q)upper(`The;(`quick`brown;(`fox;`jumps`over));`a;`lazy`dog) @@ -42,5 +39,5 @@ q)upper(`The;(`quick`brown;(`fox;`jumps`over));`a;`lazy`dog) ``` ---- -:fontawesome-solid-book-open: -[Strings](../basics/by-topic.md#strings) + +[Strings](by-topic.md#strings) diff --git a/docs/ref/lsq.md b/docs/ref/lsq.md index c648d9f41..09760b3a0 100644 --- a/docs/ref/lsq.md +++ b/docs/ref/lsq.md @@ -1,9 +1,9 @@ --- -title: lsq – least-squares matrix equation solution |Reference | kdb+ and q documentation +title: lsq – least-squares matrix equation solution |Reference | KDB-X and q documentation description: lsq is a q keyword that performs least squares fitting, matrix division. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- -![Linear regression](../img/linear-regression.png) +![Linear regression](https://code.kx.com/q/img/linear-regression.png) {: style="float: right"} # `lsq` @@ -98,14 +98,14 @@ q)A mmu inv B ---- -:fontawesome-solid-book: + [`inv`](inv.md), [`mmu`](mmu.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-brands-wikipedia-w: + [LU decomposition](https://en.wikipedia.org/wiki/LU_decomposition "Wikipedia"), [Cholesky decomposition](https://en.wikipedia.org/wiki/Cholesky_decomposition#Matrix_inversion "Wikipedia") diff --git a/docs/ref/maps.md b/docs/ref/maps.md index 50cf211b1..672776261 100644 --- a/docs/ref/maps.md +++ b/docs/ref/maps.md @@ -1,9 +1,9 @@ --- -title: Map iterators | Reference | kdb+ and q documentation +title: Map iterators | Reference | KDB-X and q documentation description: Maps iterators derive uniform functions that apply their values once to each item of a dictionary, a list, or conforming lists. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited date: March 2019 -keywords: adverb, case, dictionary, each, each both, each left, each parallel, each prior, each right, iterate, iterator, kdb+, keyword, map, mnemonic, operator, parallel, prior, q, unary +keywords: adverb, case, dictionary, each, each both, each left, each parallel, each prior, each right, iterate, iterator, KDB-X, keyword, map, mnemonic, operator, parallel, prior, q, unary --- # Map iterators @@ -21,7 +21,7 @@ v1: value (rank 1) v: value (rank 1-8) v2: value (rank 2) i: vector of ints≥0 -The maps are iterators that derive [**uniform**](../basics/glossary.md#uniform-function) functions that apply their [values](../basics/glossary.md#applicable-value) once to each item of a dictionary, a list, or conforming lists. +The maps are iterators that derive [**uniform**](glossary.md#uniform-function) functions that apply their [values](glossary.md#applicable-value) once to each item of a dictionary, a list, or conforming lists. ## Each @@ -44,7 +44,7 @@ c| 4 ``` -![each-both](../img/each-both.png) +![each-both](svg/each-both.svg)
_Each Both_ {: style="float: right; margin-left: 1em; text-align: center;"} @@ -63,7 +63,7 @@ q){x+y*z}'[1000000;1 0 1;5000 6000 7000] / ternary 1005000 1000000 1007000 ``` -!!! warning "Each is redundant with [atomic functions](../basics/atomic.md). (Common qbie mistake.)" +!!! warning "Each is redundant with [atomic functions](atomic.md)." ### `each` keyword @@ -95,7 +95,7 @@ The maps Each Left and Each Right take **binary** values and derive binary funct ------------|:--------------------------------:|:-----------------: syntax: | `x f\:y` | `x f/:y` equivalent: | `f[;y] each x` | `f[x;] each y` -  | ![Each Left](../img/each-left.png) | ![Each Right](../img/each-right.png) +  | ![Each Left](svg/each-left.svg) | ![Each Right](svg/each-right.svg) ```q q)"abcde",\:"XY" / Each Left @@ -159,13 +159,13 @@ q)raze[a] ~ b 0x400921ea35935fc4 ``` - This is [exposed infrastructure](../basics/exposed-infrastructure.md). + This is [exposed infrastructure](exposed-infrastructure.md). Use the keywords [`vs`](vs.md) and [`sv`](sv.md) instead. ## Each Parallel -![Each Parallel](../img/each-parallel.png) +![Each Parallel](svg/each-parallel.svg) {: style="float: right; margin-left: 1em;"} _Assign sublists of the argument list to secondary tasks, in which the unary value is applied to each item of the sublist._ @@ -174,16 +174,16 @@ _Assign sublists of the argument list to secondary tasks, in which the unary val (v1':)x v1':[x] v1 peach x ``` -The Each Parallel map takes a **unary** value as argument and derives a unary function. The iteration `v1':` divides its list or dictionary argument `x` between [available secondary tasks](../basics/cmdline.md#-s-secondary-threads). Each secondary task applies `v1` to each item of its sublist. +The Each Parallel map takes a **unary** value as argument and derives a unary function. The iteration `v1':` divides its list or dictionary argument `x` between [available secondary tasks](cmdline.md#-s-secondary-threads). Each secondary task applies `v1` to each item of its sublist. -:fontawesome-solid-book-open: -[Command-line option `-s`](../basics/cmdline.md#-s-secondary-threads), -[Parallel processing](../basics/peach.md) + +[Command-line option `-s`](cmdline.md#-s-secondary-threads), +[Parallel processing](../how_to/performance/performance.md#parallel-processing) ```bash ❯ q -s 2 -KDB+ 4.1t 2021.07.12 Copyright (C) 1993-2021 Kx Systems -m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 EXPIRE .. +KDB-X 5.0.20251113 2025.11.13 Copyright (C) 1993-2025 Kx Systems +... ``` ```q q)\s @@ -212,23 +212,23 @@ v1 peach list Alternatively, define the value as a function that takes a parameter dictionary as argument, and pass the derived function a table of parameters to evaluate. -:fontawesome-solid-book: + [`.Q.fc` parallel on cut](dotq.md#fc-parallel-on-cut)
-:fontawesome-solid-book-open: -[Parallel processing](../basics/peach.md) + +[Parallel processing](../how_to/performance/performance.md#parallel-processing)
-:fontawesome-solid-graduation-cap: -[Table counts in a partitioned database](../kb/partition.md#table-counts) + +[Table counts in a partitioned database](../how_to/interact_with_databases/partition.md#table-counts)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[A.68 `peach`](/q4m3/A_Built-in_Functions/#a68-peach) +[A.49 `peach`](../learn/q4m/A_Built-in_Functions.md#a49-peach) ## Each Prior -![Each Prior](../img/each-prior.png) +![Each Prior](svg/each-prior.svg) {: style="float: right; margin-left: 1em; z-index: 3"} _Apply a binary value between each item of a list and its preceding item._ @@ -278,9 +278,9 @@ q){x+2*y}':[2 3 4] 0N 7 10 ``` -:fontawesome-solid-street-view: + _Q for Mortals_ -[§6.7.9 Each Prior](/q4m3/6_Functions/#679-each-prior) +[§6.7.9 Each Prior](../learn/q4m/6_Functions.md/#679-each-prior) ### `prior` keyword @@ -314,7 +314,7 @@ Where the derived function `int'` returns $r$ such that $r_i$ is ($args_{int_i})_i$ -![case](../img/case.png) +![case](svg/case.svg) The derived function `int'` has rank `max[int]+1`. @@ -383,8 +383,8 @@ q)i'[a;b;c] `Kuh`chien`Katte`fish ``` -:fontawesome-solid-graduation-cap: -[Table counts in a partitioned database](../kb/partition.md#table-counts) + +[Table counts in a partitioned database](../how_to/interact_with_databases/partition.md#table-counts) ## Empty lists diff --git a/docs/ref/match.md b/docs/ref/match.md index c1e2d17ba..ffa6bc741 100644 --- a/docs/ref/match.md +++ b/docs/ref/match.md @@ -1,8 +1,8 @@ --- -title: Match | Reference | kdb+ and q documentation +title: Match | Reference | KDB-X and q documentation description: Match is a q operator that flags whether its arguments have the same value. -author: Stephen Taylor -keywords: compare, kdb+, q, value +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: compare, KDB-X, q, value --- # `~` Match @@ -13,7 +13,7 @@ keywords: compare, kdb+, q, value x~y ~[x;y] ``` -Returns `0b` unless `x` and `y` are identical. [Comparison tolerance](../basics/precision.md#comparison-tolerance) is used when matching floats. +Returns `0b` unless `x` and `y` are identical. [Comparison tolerance](precision.md#comparison-tolerance) is used when matching floats. ```q q)(1 2 3+4 5 6)~4 5 6+1 2 3 / the arguments are identical @@ -69,11 +69,11 @@ q)t1~t2 ``` --- -:fontawesome-solid-book: + [Equal `=`](equal.md), [Not Equal `<>`](not-equal.md)
-:fontawesome-solid-book-open: -[Comparison](../basics/comparison.md) + +[Comparison](comparison.md)
-:fontawesome-solid-street-view: -_Q for Mortals_: [§4.2 Match](/q4m3/4_Operators/#42-match) + +_Q for Mortals_: [§4.2 Match](../learn/q4m/4_Operators.md/#42-match) diff --git a/docs/ref/max.md b/docs/ref/max.md index c8a236173..f3fb33ea3 100644 --- a/docs/ref/max.md +++ b/docs/ref/max.md @@ -1,14 +1,10 @@ --- -title: Maximums | Reference | kdb+ and q documentation +title: Maximums | Reference | KDB-X and q documentation description: max, maxs, and mmax are q keywords that return respectively the largest item from a list or dictionary, the cumulative maximums, and the moving maximums. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `max`, `maxs`, `mmax` - - - - ## `max` _Maximum_ @@ -18,7 +14,7 @@ max x max[x] ``` Where `x` is a non-symbol sortable list, returns the maximum of its items. -The maximum of an atom is itself. +The maximum of an atom is itself. Nulls are ignored, except that if the items of `x` are all nulls, the result is negative infinity. @@ -41,8 +37,7 @@ domain: b g x h i j e f c s p m d z n u v t range: b . x h i j e f c . p m d z n u v t ``` -`max` is a [multithreaded primitive](../kb/mt-primitives.md). - +`max` is a [multithreaded primitive](mt-primitives.md). ## `maxs` @@ -52,7 +47,7 @@ _Maximums_ maxs x maxs[x] ``` -Where `x` is a non-symbol sortable list, returns the running maximums of its prefixes. +Where `x` is a non-symbol sortable list, returns the running maximums of its prefixes. Nulls are ignored, except that initial nulls are returned as negative infinity. @@ -72,7 +67,6 @@ domain: b g x h i j e f c s p m d z n u v t range: b . x h i j e f c . p m d z n u v t ``` - ## `mmax` _Moving maximums_ @@ -83,8 +77,8 @@ x mmax y mmax[x;y] Where -- `x` is a positive int atom -- `y` is a non-symbol sortable list +- `x` is a positive int atom +- `y` is a non-symbol sortable list returns the `x`-item moving maximums of `y`, with nulls after the first replaced by the preceding maximum. The first `x` items of the result are the maximums of the items so far, and thereafter the result is the moving maximum. @@ -98,6 +92,7 @@ q)3 mmax 0N -3 -2 0N 1 0 / initial null returns negative infinity `mmax` is a uniform function. Domain and range: + ```txt b g x h i j e f c s p m d z n u v t ---------------------------------------- @@ -123,10 +118,9 @@ t | . . . . . . . . . . . . . . . . . . Range: `bcdefghijmnpstuvxz` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`max`, `maxs`, and `mmax` apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`max`, `maxs`, and `mmax` apply to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)max`a`b!(10 21 3;4 5 6) @@ -163,7 +157,6 @@ def| 21 5 ghi| 21 6 ``` - ## Aggregating nulls `avg`, `min`, `max` and `sum` are special: they ignore nulls, in order to be similar to SQL92. @@ -174,15 +167,13 @@ q)max (1 2;0N 4) 1 4 ``` - ---- -:fontawesome-solid-book: + [Greater Than](greater-than.md)
-:fontawesome-solid-book-open: -[Comparison](../basics/comparison.md), -[Mathematics](../basics/math.md) + +[Comparison](comparison.md), +[Mathematics](math.md)
-:fontawesome-solid-graduation-cap: -[Sliding windows](../kb/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) +[Sliding windows](../examples/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) diff --git a/docs/ref/md5.md b/docs/ref/md5.md index e286f4795..af3b931c3 100644 --- a/docs/ref/md5.md +++ b/docs/ref/md5.md @@ -1,7 +1,7 @@ --- -title: md5 – message Digest Algorithm 5 hash | Reference | kdb+ and q documentation +title: md5 – message Digest Algorithm 5 hash | Reference | KDB-X and q documentation description: md5 is a q keyword that returns the Message Digest (MD5 hash) of a string. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `md5` @@ -24,5 +24,5 @@ MD5 is a widely used, Internet standard (RFC 1321), hash function that computes ---- -:fontawesome-solid-book-open: -[Strings](../basics/by-topic.md#strings) \ No newline at end of file + +[Strings](by-topic.md#strings) \ No newline at end of file diff --git a/docs/ref/med.md b/docs/ref/med.md index 67f61370c..b642e6dc4 100644 --- a/docs/ref/med.md +++ b/docs/ref/med.md @@ -1,13 +1,10 @@ --- -title: median of a numeric list | Reference | kdb+ and q documentation +title: median of a numeric list | Reference | KDB-X and q documentation description: med is a q keyword that returns the median of its argument. -keywords: kdb+, median, q, statistics +keywords: KDB-X, median, q, statistics --- # `med` - - - _Median_ ```syntax @@ -22,7 +19,7 @@ q)med 10 34 23 123 5 56 q)select med price by sym from trade where date=2001.10.10,sym in`AAPL`LEH ``` -`med` is an aggregate function, equivalent to +`med` is an aggregate function, equivalent to ```q {avg x (iasc x)@floor .5*-1 0+count x,:()} @@ -35,10 +32,9 @@ domain: b g x h i j e f c s p m d z n u v t range: f . f f f f f f f . f f f f f f f f ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`med` applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`med` applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -55,10 +51,9 @@ a| 3 b| -6 ``` - ## Partitions and segments -`med` signals a part error when running a median over partitions, or segments. +`med` signals a part error when running a median over partitions, or segments. (Since V3.5 2017.01.18; from V3.0 it signalled a rank error.) This is deliberate, as previously `med` was returning median of medians for such cases. This should now be explicitly coded as a cascading select. @@ -70,7 +65,6 @@ select med price by sym from sym in `AAPL`LEH ``` - ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/meta.md b/docs/ref/meta.md index ad7d18803..21981b43b 100644 --- a/docs/ref/meta.md +++ b/docs/ref/meta.md @@ -1,7 +1,7 @@ --- -title: meta – metadata for a table| Reference | kdb+ and q documentation +title: meta – metadata for a table| Reference | KDB-X and q documentation description: meta is a q keyword that returns metadata for a table. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `meta` @@ -76,13 +76,13 @@ c | t f a code| s vr | F ``` -!!! warning "The result of `meta` does not tell you whether a table in memory can be [splayed](../kb/splayed-tables.md), only the first item in each column is examined" +!!! warning "The result of `meta` does not tell you whether a table in memory can be [splayed](../how_to/interact_with_databases/splayed-tables.md), only the first item in each column is examined" A splayed table with a symbol column needs its corresponding sym list. ```q -KDB+ 4.0 2020.10.02 Copyright (C) 1993-2020 Kx Systems -m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 EXPIRE .. +KDB-X 0.1.2 2025.10.18 Copyright (C) 1993-2025 Kx Systems +... q)load `:db/sym / required for meta to describe db/tr `sym @@ -102,8 +102,8 @@ Loading (memory mapping) a database handles this. ❯ q db ``` ```q -KDB+ 4.0 2020.10.02 Copyright (C) 1993-2020 Kx Systems -m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 EXPIRE 2021.05.27 stephen@kx.com #59875 +KDB-X 0.1.2 2025.10.18 Copyright (C) 1993-2025 Kx Systems +... q)\v `s#`sym`tr @@ -119,9 +119,8 @@ price| f --- -:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) + +[Metadata](metadata.md)
-:fontawesome-solid-graduation-cap: -[Splayed tables](../kb/splayed-tables.md) +[Splayed tables](../how_to/interact_with_databases/splayed-tables.md) diff --git a/docs/ref/min.md b/docs/ref/min.md index 8a8a556cf..2fee0163b 100644 --- a/docs/ref/min.md +++ b/docs/ref/min.md @@ -1,15 +1,12 @@ --- -title: min, mins, mmin – minima of a list | Reference | kdb+ and q documentation +title: min, mins, mmin – minima of a list | Reference | KDB-X and q documentation description: min, mins and mmin are q keywords that return respectively the smallest item, the cumulative minimums, and the moving minimums of the argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `min`, `mins`, `mmin` _Minimum/s_ - - - ## `min` _Minimum_ @@ -18,8 +15,8 @@ _Minimum_ min x min[x] ``` -Where `x` is a non-symbol sortable list, returns its minimum. -The minimum of an atom is itself. +Where `x` is a non-symbol sortable list, returns its minimum. +The minimum of an atom is itself. Nulls are ignored, except that if the argument has only nulls, the result is infinity. @@ -37,8 +34,7 @@ q)select min price by sym from t / use in a select statement `min` is an aggregate function, equivalent to `&/`. -`min` is a [multithreaded primitive](../kb/mt-primitives.md). - +`min` is a [multithreaded primitive](mt-primitives.md). ## `mins` @@ -63,7 +59,6 @@ q)mins 0N 5 0N 1 3 / initial nulls return infinity `mins` is a uniform function, equivalent to `&\`. - ## `mmin` _Moving minimums_ @@ -72,10 +67,10 @@ _Moving minimums_ x mmin y mmin[x;y] ``` -Where `y` is a non-symbol sortable list and `x` is a +Where `y` is a non-symbol sortable list and `x` is a -- positive int atom, returns the `x`-item moving minimums of `y`, with nulls treated as the minimum value; the first `x` items of the result are the minimums of the terms so far, and thereafter the result is the moving minimum -- 0 or a negative int, returns `y` +- positive int atom, returns the `x`-item moving minimums of `y`, with nulls treated as the minimum value; the first `x` items of the result are the minimums of the terms so far, and thereafter the result is the moving minimum +- 0 or a negative int, returns `y` ```q q)3 mmin 0N -3 -2 1 -0W 0 @@ -86,19 +81,19 @@ q)3 mmin 0N -3 -2 1 0N -0W / null is the minimum value `mmin` is a uniform function. -:fontawesome-solid-graduation-cap: -[Sliding windows](../kb/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) - +[Sliding windows](../examples/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) ## Domain and range `min` and `mins` + ```txt domain: b g x h i j e f c s p m d z n u v t range: b . x h i j e f c . p m d z n u v t ``` `mmin` + ```txt b g x h i j e f c s p m d z n u v t ---------------------------------------- @@ -124,10 +119,9 @@ t | . . . . . . . . . . . . . . . . . . Range: `bcdefghijmnpstuvxz` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`min`, `mins`, and `mmin` apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`min`, `mins`, and `mmin` apply to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) @@ -166,10 +160,9 @@ q)min (1 2;0N 4) 0N 2 ``` - ---- -:fontawesome-solid-book: + [`max`, `maxs`, `mmax`](max.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/mmu.md b/docs/ref/mmu.md index 18747b04a..9191a7c62 100644 --- a/docs/ref/mmu.md +++ b/docs/ref/mmu.md @@ -1,10 +1,10 @@ --- -title: Matrix Multiply, mmu – Reference – kdb+ and q documentation +title: Matrix Multiply, mmu – Reference – KDB-X and q documentation description: Matrix Multiply is a q operator that performs matrix multiplication; mmu is a q keyword that is a wrapper for it. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- -![Matrix multiplication](../img/matrix-multiplication.png) +![Matrix multiplication](https://code.kx.com/q/img/matrix-multiplication.png) {: style="float:right"} # `$` Matrix Multiply, `mmu` @@ -59,11 +59,11 @@ q)mmu[;b]peach a ``` ---- -:fontawesome-solid-book: + [Overloads of `$`](overloads.md#dollar)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-brands-wikipedia-w: + [Matrix multiplication](https://en.wikipedia.org/wiki/Matrix_multiplication "Wikipedia") \ No newline at end of file diff --git a/docs/ref/mod.md b/docs/ref/mod.md index 643e747a3..70d0ad6ab 100644 --- a/docs/ref/mod.md +++ b/docs/ref/mod.md @@ -1,15 +1,13 @@ --- -title: mod | Reference | kdb+ and q documentation +title: mod | Reference | KDB-X and q documentation description: mod is a q keyword that returns the modulus of a number. -author: Stephen Taylor -keywords: kdb+, math, mathematics, modulus, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: KDB-X, math, mathematics, modulus, q --- # `mod` _Modulus_ - - ```syntax x mod y mod[x;y] ``` @@ -28,12 +26,11 @@ q)-7 7 mod/:\:-2.5 -2 2 2.5 -0.5 -1 1 2 ``` -`mod` is a [multithreaded primitive](../kb/mt-primitives.md). +`mod` is a [multithreaded primitive](mt-primitives.md). +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`mod` is an [atomic function](../basics/atomic.md). +`mod` is an [atomic function](atomic.md). ```q q)(10;20 30)mod(7 13;-12) @@ -41,7 +38,7 @@ q)(10;20 30)mod(7 13;-12) -4 -6 ``` -It applies to [dictionaries and keyed tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and keyed tables](math.md#dictionaries-and-tables). ```q q)d mod 5 @@ -60,7 +57,6 @@ def| 4 0 ghi| 3 4 ``` - ## Domain and range ```txt @@ -89,11 +85,11 @@ t | t . t t t t t f t . . . . . . . . . Range: `defijmnptuvz` ---- -:fontawesome-solid-book: -[`%` Divide](divide.md), [`div`](div.md), [`reciprocal`](reciprocal.md) + +[`%` Divide](divide.md), [`div`](div.md), [`reciprocal`](reciprocal.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-solid-street-view: -_Q for Mortals_: [§4.8.1 Integer Division `div` and Modulus `mod`](/q4m3/4_Operators/#481-integer-division-div-and-modulus-mod) + +_Q for Mortals_: [§4.8.1 Integer Division `div` and Modulus `mod`](../learn/q4m/4_Operators.md/#481-integer-division-div-and-modulus-mod) diff --git a/docs/ref/multiply.md b/docs/ref/multiply.md index fa0085fb1..f3d031de4 100644 --- a/docs/ref/multiply.md +++ b/docs/ref/multiply.md @@ -1,7 +1,7 @@ --- -title: Multiply | Reference | kdb+ and q documentation +title: Multiply | Reference | KDB-X and q documentation description: Multiply is a q operator that returns the product of its arguments. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `*` Multiply @@ -12,7 +12,7 @@ author: Stephen Taylor x*y *[x;y] ``` -Where `x` and `y` are [conformable](../basics/conformable.md) numerics or temporals, returns their +Where `x` and `y` are [conformable](conformable.md) numerics or temporals, returns their product. ```q @@ -40,12 +40,12 @@ price qty 34.5 17 ``` -`*` is a [multithreaded primitive](../kb/mt-primitives.md). +`*` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -Multiply is an [atomic function](../basics/atomic.md). +Multiply is an [atomic function](atomic.md). ```q q)(10;20 30)*(2;3 4) @@ -53,7 +53,7 @@ q)(10;20 30)*(2;3 4) 60 120 ``` -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -86,7 +86,7 @@ ghi| 9 36 ## Range and domains The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt b g x h i j e f c s p m d z n u v t @@ -125,12 +125,12 @@ q)type 1i*55 ``` ---- -:fontawesome-solid-book: + [Divide](divide.md), [`prd`, `prds`](prd.md), [`.Q.addmonths`](dotq.md#addmonths)
-:fontawesome-solid-book-open: -[Datatypes](../basics/datatypes.md), -[Mathematics](../basics/math.md) + +[Datatypes](datatypes.md), +[Mathematics](math.md) diff --git a/docs/ref/neg.md b/docs/ref/neg.md index 559bc11bb..263b02108 100644 --- a/docs/ref/neg.md +++ b/docs/ref/neg.md @@ -1,7 +1,7 @@ --- -title: neg | Reference | kdb+ and q documentation +title: neg | Reference | KDB-X and q documentation description: neg is a q keyword that returns the negation of its argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `neg` @@ -34,7 +34,7 @@ q)neg 2000.01.01 2012.01.01 / negates the underlying data value An atomic function. -`neg` is a [multithreaded primitive](../kb/mt-primitives.md). +`neg` is a [multithreaded primitive](mt-primitives.md). ## Domain and range @@ -48,17 +48,17 @@ Range: `ihjefpmdznuvt` ---- -:fontawesome-solid-book: + [`not`](not.md), [Subtract](subtract.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.3.2 Not Zero `not`](/q4m3//4_Operators/#431-equality-and-disequality) +[§4.3.2 Not Zero `not`](../learn/q4m/4_Operators.md#432-not-not)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.9.2 Temporal Arithmetic](/q4m3/4_Operators/#492-temporal-arithmetic) +[§4.9.2 Temporal Arithmetic](../learn/q4m/4_Operators.md/#492-temporal-arithmetic) diff --git a/docs/ref/next.md b/docs/ref/next.md index e80b5ac8a..230a625a1 100644 --- a/docs/ref/next.md +++ b/docs/ref/next.md @@ -1,7 +1,7 @@ --- -title: next, prev, xprev – immediate or near neighbors of the items of a list | Reference | kdb+ and q documentation +title: next, prev, xprev – immediate or near neighbors of the items of a list | Reference | KDB-X and q documentation description: next, prev, and xprev are q keywords that return the immediate or near neighbors of the items of a list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `next`, `prev`, `xprev` @@ -109,9 +109,9 @@ q)1 xprev "abcde" ---- -:fontawesome-solid-book: -[Each Prior](../ref/maps.md#each-prior) + +[Each Prior](maps.md#each-prior)
-:fontawesome-solid-book-open: -[Selection](../basics/by-topic.md#selection) + +[Selection](by-topic.md#selection) diff --git a/docs/ref/not-equal.md b/docs/ref/not-equal.md index 687923406..be005dee6 100644 --- a/docs/ref/not-equal.md +++ b/docs/ref/not-equal.md @@ -1,8 +1,8 @@ --- -title: Not Equal | Reference | kdb+ and q documentation +title: Not Equal | Reference | KDB-X and q documentation description: Not Equal is a q operator that flags whether its arguments have the same value. -author: Stephen Taylor -keywords: compare, equal, kdb+, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: compare, equal, KDB-X, q --- # `<>` Not Equal @@ -21,11 +21,11 @@ q)(3;"a")<>(2 3 4;"abc") ``` --- -:fontawesome-solid-book: + [Equal `=`](equal.md)
-:fontawesome-solid-book-open: -[Comparison](../basics/comparison.md) + +[Comparison](comparison.md)
-:fontawesome-solid-street-view: -_Q for Mortals_: [§4.3.1 Equality = and Disequality <>](/q4m3/4_Operators/#431-equality-and-disequality) + +_Q for Mortals_: [§4.3.1 Equality = and Inequality <>](../learn/q4m/4_Operators.md#431-equality-and-inequality) diff --git a/docs/ref/not.md b/docs/ref/not.md index 5285df4be..a63a0dbfd 100644 --- a/docs/ref/not.md +++ b/docs/ref/not.md @@ -1,8 +1,8 @@ --- -title: not | Reference | kdb+ and q documentation +title: not | Reference | KDB-X and q documentation description: not is a q keyword that flags whether its argument is false. -author: Stephen Taylor -keywords: false, kdb+, logic, not, q, true +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: false, KDB-X, logic, not, q, true --- # `not` @@ -46,15 +46,15 @@ q)not (0W;-0w;0N) An atomic function. -`not` is a [multithreaded primitive](../kb/mt-primitives.md). +`not` is a [multithreaded primitive](mt-primitives.md). --- -:fontawesome-solid-book: + [`neg`](neg.md)
-:fontawesome-solid-book-open: -[Logic](../basics/by-topic.md#logic) + +[Logic](by-topic.md#logic)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.3.2 Not Zero `not`](/q4m3//4_Operators/#431-equality-and-disequality) +[§4.3.2 Not Zero `not`](../learn/q4m/4_Operators.md#432-not-not) diff --git a/docs/ref/null.md b/docs/ref/null.md index 8a11d7b46..1684b8448 100644 --- a/docs/ref/null.md +++ b/docs/ref/null.md @@ -1,7 +1,7 @@ --- -title: Flag nulls in a list or dictionary | Reference | kdb+ and q documentation +title: Flag nulls in a list or dictionary | Reference | KDB-X and q documentation description: null is a q keyword that flags where its argument is null. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `null` @@ -52,6 +52,6 @@ q)\ts `=v 66 268435648 ``` -`null` is a [multithreaded primitive](../kb/mt-primitives.md). +`null` is a [multithreaded primitive](mt-primitives.md). diff --git a/docs/ref/or.md b/docs/ref/or.md index b7a4de491..8d9368e57 100644 --- a/docs/ref/or.md +++ b/docs/ref/or.md @@ -1,18 +1,18 @@ --- -title: or – Reference – kdb+ and q documentation +title: or – Reference – KDB-X and q documentation description: or is a q keyword that performs a logical OR. -author: Stephen Taylor -keywords: and, greater, kdb+, logic, or, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: and, greater, KDB-X, logic, or, q --- # `or` _Greater of two values, logical OR_ -`or` is a [multithreaded primitive](../kb/mt-primitives.md). +`or` is a [multithreaded primitive](mt-primitives.md). -:fontawesome-regular-hand-point-right: + [Greater](greater.md) diff --git a/docs/ref/over.md b/docs/ref/over.md index de376c37d..8196d71e8 100644 --- a/docs/ref/over.md +++ b/docs/ref/over.md @@ -1,7 +1,7 @@ --- -title: over, scan – wrappers for the Over and Scan accumulating iterators | Reference | kdb+ and q documentation +title: over, scan – wrappers for the Over and Scan accumulating iterators | Reference | KDB-X and q documentation description: over and scan are q keywords that are wrappers for the Over and Scan accumulating iterators. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited date: March 2019 --- # `over`, `scan` @@ -26,10 +26,10 @@ See the [Accumulators](accumulators.md) for a more detailed discussion. Where -- `v1` is a unary [applicable value](../basics/glossary.md#applicable-value) -- `vv` is a [variadic](../basics/variadic.md) applicable value +- `v1` is a unary [applicable value](glossary.md#applicable-value) +- `vv` is a [variadic](variadic.md) applicable value -applies the value progressively to `x`, then to `v1[x]` (or `vv[x]`), and so on, until the result matches (within [comparison tolerance](../basics/precision.md#comparison-tolerance)) either +applies the value progressively to `x`, then to `v1[x]` (or `vv[x]`), and so on, until the result matches (within [comparison tolerance](precision.md#comparison-tolerance)) either - the previous result; or - `x`. @@ -55,9 +55,9 @@ and for the related forms Do and While. v2 over x over[v2;x] v2 scan x scan[v2;x] ``` -Where `v2` is a binary [applicable value](../basics/glossary.md#applicable-value), applies `v2` progressively between successive items. +Where `v2` is a binary [applicable value](glossary.md#applicable-value), applies `v2` progressively between successive items. -`scan[v2;]` is a [uniform function](../basics/glossary.md#uniform-function) and `over[v2;]` is an [aggregate function](../basics/glossary.md#aggregate-function). +`scan[v2;]` is a [uniform function](glossary.md#uniform-function) and `over[v2;]` is an [aggregate function](glossary.md#aggregate-function). ```q q)(+) scan 1 2 3 4 5 @@ -95,5 +95,5 @@ sums scan[+;] +\ Add Scan ---- -:fontawesome-solid-book: + [Accumulators](accumulators.md) diff --git a/docs/ref/overloads.md b/docs/ref/overloads.md index 032e2f104..e0c161be5 100644 --- a/docs/ref/overloads.md +++ b/docs/ref/overloads.md @@ -1,7 +1,7 @@ --- -title: Overloaded glyphs | Reference | kdb+ and q documentation +title: Overloaded glyphs | Reference | KDB-X and q documentation description: Many non-alphabetic keyboard characters are overloaded by q. This page tabulates their different forms. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # Overloaded glyphs @@ -30,7 +30,7 @@ rank | syntax | semantics rank | syntax | semantics :---:|------------------------|--------------------------------------- n/a | `\` | ends multiline comment -n/a | `\` | [Abort](../basics/syscmds.md#terminate), [Toggle](../basics/syscmds.md#toggle-qk) +n/a | `\` | [Abort](syscmds.md#terminate), [Toggle](syscmds.md#toggle-qk) 1 | `(u\)`, `u\[d]` | [Converge](accumulators.md#converge) 2 | `n u\d`, `u\[n;d]` | [Do](accumulators.md#do) 2 | `t u\d`, `u\[t;d]` | [While](accumulators.md#while) @@ -54,8 +54,8 @@ rank | syntax | semantics 2 | `noasv!iv` | [Enumeration](enumeration.md) from index 2 | `sv!h` | [Flip Splayed or Partitioned](flip-splayed.md) 2 | `0N!y` | [display](display.md) `y` and return it -2 | `-i!y` | [internal function](../basics/internal.md) -4 | `![t;c;b;a]` | [Update, Delete](../basics/funsql.md) +2 | `-i!y` | [internal function](internal.md) +4 | `![t;c;b;a]` | [Update, Delete](funsql.md) ```txt a: select specifications @@ -76,15 +76,15 @@ x,y: same-length lists
a:42 [assign](assign.md) -:42 [explicit return](../basics/function-notation.md#explicit-return) +:42 [explicit return](function-notation.md#explicit-return)
## `::` colon colon
-v::select from t where a in b [define a view](../learn/views.md) -global::42 [amend a global from within a lambda](../basics/function-notation.md#name-scope) +v::select from t where a in b [define a view](https://code.kx.com/q/learn/views/) +global::42 [amend a global from within a lambda](function-notation.md#name-scope) :: [Identity](identity.md) :: [Null](identity.md#null)
@@ -115,7 +115,7 @@ rank | syntax | semantics 4 | `.[d;i;m;my]` | [Amend](amend.md) 4 | `.[d;i;:;y]` | [Replace](amend.md) -In the [Debugger](../basics/debug.md), push the stack. +In the [Debugger](../how_to/working-with-code/debug.md), push the stack. ## `$` dollar @@ -148,10 +148,10 @@ rank | example | semantics 2 | `0N?1000`, ``0N?`yes`no`` | [Permute](deal.md#permute) 2 | `x?v` | extend an enumeration: [Enum Extend](enum-extend.md) 3 | `?[11011b;"black";"flock"]` | [Vector Conditional](vector-conditional.md) -3 | `?[t;i;p]` | [Simple Exec](../basics/funsql.md#simple-exec) -4 | `?[t;c;b;a]` | [Select](../basics/funsql.md#select), [Exec](../basics/funsql.md#exec) -5 | `?[t;c;b;a;n]` | [Select](../basics/funsql.md#rank-5) -6 | `?[t;c;b;a;n;(g;cn)]` | [Select](../basics/funsql.md#rank-6) +3 | `?[t;i;p]` | [Simple Exec](funsql.md#simple-exec) +4 | `?[t;c;b;a]` | [Select](funsql.md#select), [Exec](funsql.md#exec) +5 | `?[t;c;b;a;n]` | [Select](funsql.md#rank-5) +6 | `?[t;c;b;a;n;(g;cn)]` | [Select](funsql.md#rank-6) ## `'` quote @@ -235,6 +235,6 @@ rank | example | semantics Many of the operators tabulated above have unary forms in k. -:fontawesome-regular-hand-point-right: [Exposed infrastructure](../basics/exposed-infrastructure.md#unary-forms) + [Exposed infrastructure](exposed-infrastructure.md#unary-forms) diff --git a/docs/ref/pad.md b/docs/ref/pad.md index 44c60c66c..b3e8787ff 100644 --- a/docs/ref/pad.md +++ b/docs/ref/pad.md @@ -1,19 +1,18 @@ --- -title: Pad strings to a specified length | Reference | kdb+ and q documentation +title: Pad strings to a specified length | Reference | KDB-X and q documentation description: Pad is a q operator that pads a string or list of strings to a specified length -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `$` Pad - ```syntax x$y $[x;y] ``` -Where +Where -- `x` is a long -- `y` is a string +- `x` is a long +- `y` is a string returns `y` padded to length `x`. @@ -24,10 +23,9 @@ q)-9$"foo" " foo" ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -Pad is [string-atomic](../basics/atomic.md#string-atomic) and applies to dictionaries and tables. +Pad is [string-atomic](atomic.md#string-atomic) and applies to dictionaries and tables. ```q q)9$("The";("fox";("jumps";"over"));("the";"dog")) / string-atomic @@ -63,10 +61,8 @@ q)9h$("quick";"brown";"fox") 102 111 120f ``` -:fontawesome-solid-book: [Overloads of dollar](overloads.md#dollar) - ---- -:fontawesome-solid-book-open: -[Strings](../basics/by-topic.md#strings) \ No newline at end of file + +[Strings](by-topic.md#strings) diff --git a/docs/ref/parse.md b/docs/ref/parse.md index a5b9729b5..0251e61b2 100644 --- a/docs/ref/parse.md +++ b/docs/ref/parse.md @@ -1,7 +1,7 @@ --- -title: parse | Reference | kdb+ and q documentation +title: parse | Reference | KDB-X and q documentation description: parse is a q keyword that returns a parse tree for a string expression. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # parse @@ -115,8 +115,8 @@ q)views[] ---- -:fontawesome-solid-book: + [`eval` and `reval`](eval.md)
-:fontawesome-solid-book-open: -[Parse trees](../basics/parsetrees.md) + +[Parse trees](parsetrees.md) diff --git a/docs/ref/pj.md b/docs/ref/pj.md index 8716152a7..40200d7fb 100644 --- a/docs/ref/pj.md +++ b/docs/ref/pj.md @@ -1,7 +1,7 @@ --- -title: pj – plus join | Reference | kdb+ and q documentation +title: pj – plus join | Reference | KDB-X and q documentation description: pj is a q keyword that performs a plus join. -keywords: join, kdb+, pj,plus join, q +keywords: join, KDB-X, pj,plus join, q --- # `pj` @@ -55,10 +55,10 @@ a b c d In the example above, `pj` is equivalent to `` x+0^y[`a`b#x] `` (compute the value of `y` on `a` and `b` columns of `x`, fill the result with zeros and add to `x`). --- -:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.9.6 Plus Join](/q4m3/9_Queries_q-sql/#996-plus-join-pj) +[§9.9.6 Plus Join](../learn/q4m/9_Queries_q-sql.md/#996-plus-join-pj) diff --git a/docs/ref/prd.md b/docs/ref/prd.md index 2cc15cea0..7f3a43688 100644 --- a/docs/ref/prd.md +++ b/docs/ref/prd.md @@ -1,16 +1,12 @@ --- -title: prd, prds – product and running products | Reference | kdb+ and q documentation +title: prd, prds – product and running products | Reference | KDB-X and q documentation description: prd and prds are q keywords that return respectively the product and the cumulating products of their arguments. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `prd`, `prds` _Product/s_ - - - - ## `prd` _Product_ @@ -40,7 +36,6 @@ q)prd "abc" `prd` is an aggregate function, equivalent to `*/`. - ## `prds` _Products_ @@ -49,7 +44,7 @@ _Products_ prds x prds[x] ``` -Where `x` is a numeric list, returns the cumulative products of its items. +Where `x` is a numeric list, returns the cumulative products of its items. ```q q)prds 7 / atom is returned unchanged @@ -67,10 +62,9 @@ q)prds "abc" / type error if list is not numeric `prds` is a uniform function, equivalent to `*\`. +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`prd` and `prds` apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`prd` and `prds` apply to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) @@ -118,8 +112,8 @@ def| 210 20 ghi| 630 120 ``` - ## Domains and ranges + ```txt domain: b g x h i j e f c s p m d z n u v t range: i . i i i j e f i . p m d z n u v t @@ -127,8 +121,7 @@ range: i . i i i j e f i . p m d z n u v t ---- -:fontawesome-solid-book: [Multiply](multiply.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/prior.md b/docs/ref/prior.md index 4e52d58a1..eb743ed9a 100644 --- a/docs/ref/prior.md +++ b/docs/ref/prior.md @@ -1,7 +1,7 @@ --- -title: prior – a wrapper for the Each Prior iterator | Reference | kdb+ and q documentation +title: prior – a wrapper for the Each Prior iterator | Reference | KDB-X and q documentation description: prior is a q keyword that is a wrapper for the Each Prior iterator. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited date: March 2019 --- # `prior` @@ -15,12 +15,12 @@ date: March 2019 Where -- `v2` is a binary [applicable value](../basics/glossary.md#applicable-value) -- `vv` is a [variadic](../basics/variadic.md) applicable value +- `v2` is a binary [applicable value](glossary.md#applicable-value) +- `vv` is a [variadic](variadic.md) applicable value applies `v2` or `vv` to each item of `x` and the item preceding it, and returns a result of the same length. -That is, the projections `prior[v2;]` and `prior[vv;]` are [uniform](../basics/glossary.md#uniform-function) functions. +That is, the projections `prior[v2;]` and `prior[vv;]` are [uniform](glossary.md#uniform-function) functions. ```q q)(+) prior til 10 @@ -37,5 +37,5 @@ See the [iterator](maps.md#each-prior) for how the first item of the result is d ---- -:fontawesome-solid-book: + [Each Prior](maps.md#each-prior) \ No newline at end of file diff --git a/docs/ref/rand.md b/docs/ref/rand.md index 1bde81e5e..9d26660d3 100644 --- a/docs/ref/rand.md +++ b/docs/ref/rand.md @@ -1,8 +1,8 @@ --- -title: rand | Reference | kdb+ and q documentation +title: rand | Reference | KDB-X and q documentation description: rand is a q keyword that randomly picks a number, or an item from a list. -author: Stephen Taylor -keywords: deal, kdb+, q, rand, random, roll +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: deal, KDB-X, q, rand, random, roll --- # `rand` @@ -61,5 +61,5 @@ Right domain and range are as for [Roll and Deal](deal.md#generate). --- -:fontawesome-solid-book: + [Random seed](deal.md#seed) \ No newline at end of file diff --git a/docs/ref/rank.md b/docs/ref/rank.md index a18a84161..599ab029d 100644 --- a/docs/ref/rank.md +++ b/docs/ref/rank.md @@ -1,7 +1,7 @@ --- -title: rank – position of the items of its argument in the sorted list | Reference | kdb+ and q documentation +title: rank – position of the items of its argument in the sorted list | Reference | KDB-X and q documentation description: rank is a q keyword that returns the position of the items of its argument in the sorted list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `rank` @@ -35,8 +35,8 @@ q)iasc idesc 2 7 3 2 5 / descending rank ``` ---- -:fontawesome-solid-book: + [`iasc`](asc.md#iasc)
-:fontawesome-solid-book-open: -[Sorting](../basics/by-topic.md#sort) + +[Sorting](by-topic.md#sort) diff --git a/docs/ref/ratios.md b/docs/ref/ratios.md index 97f297841..9ca5d9e09 100644 --- a/docs/ref/ratios.md +++ b/docs/ref/ratios.md @@ -1,15 +1,10 @@ --- -title: ratios between successive items of a list | Reference | kdb+ and q documentation +title: ratios between successive items of a list | Reference | KDB-X and q documentation description: ratios is a q keyword that returns the ratios between successive items of a list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `ratios` - - - - - _Ratios between items_ ```syntax @@ -44,10 +39,9 @@ price| x 1 | 252 ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`ratios` applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`ratios` applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 21 3;4 5 6) @@ -73,7 +67,7 @@ ghi| 0.1428571 1.2 ## First predecessor -The predecessor of the first item is 1. +The predecessor of the first item is 1. ```q q)ratios 2000 2005 2007 2012 2020 @@ -95,16 +89,11 @@ q)ratios0 2000 2005 2007 2012 2020 However, `ratios` is supported only as a unary function. For binary application, use the derived function. - - - ---- -:fontawesome-solid-book: + [Each Prior](maps.md#each-prior), [`differ`](differ.md), [Divide](divide.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) - +[Mathematics](math.md) diff --git a/docs/ref/raze.md b/docs/ref/raze.md index 3ca879478..d5d3e8086 100644 --- a/docs/ref/raze.md +++ b/docs/ref/raze.md @@ -1,7 +1,7 @@ --- -title: raze joins the items of a list, collapsing one level of nesting | Reference | kdb+ and q documentation +title: raze joins the items of a list, collapsing one level of nesting | Reference | KDB-X and q documentation description: raze is a q keyword that returns the items of a list joined, collapsing one level of nesting. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `raze` @@ -59,5 +59,5 @@ q)raze (10;d) / raze will not work ---- -:fontawesome-solid-book: + [Join](join.md) \ No newline at end of file diff --git a/docs/ref/read0.md b/docs/ref/read0.md index c4bccd0c5..5857b0799 100644 --- a/docs/ref/read0.md +++ b/docs/ref/read0.md @@ -1,10 +1,11 @@ --- -title: read0 reads text | Reference | kdb+ and q documentation +title: read0 reads text | Reference | KDB-X and q documentation description: read0 is a q keyword that reads text from a file or process handle -author: Stephen Taylor -keywords: file, filesystem, filehandle, handle, kdb+, lines, pipe, process, q, read, read0, text +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: file, filesystem, filehandle, handle, KDB-X, lines, pipe, process, q, read, read0, text --- -# :fontawesome-solid-database: `read0` + +# `read0` _Read text from a file or process handle_ @@ -18,14 +19,13 @@ read0 (fifo;n) read0[(fifo;n)] where -- `f` is a [file symbol](../basics/glossary.md#file-symbol) -- `o` is an offset as a non-negative integer/long -- `h` is a [system or connection handle](../basics/handles.md) -- `fifo` is a communication handle to a [Fifo](hopen.md#communication-handles) -- `n` is a non-negative integer - -returns character data from the source as follows. +- `f` is a [file symbol](glossary.md#file-symbol) +- `o` is an offset as a non-negative integer/long +- `h` is a [system or connection handle](handles.md) +- `fifo` is a communication handle to a [Fifo](hopen.md#communication-handles) +- `n` is a non-negative integer +returns character data from the source as follows. ## File symbol @@ -41,7 +41,6 @@ q)/ read 500000 lines, chunks of (up to) 100000 at a time q)d:raze{read0(`:/tmp/data;x;100000)}each 100000*til 5 ``` - ## File symbol with offset Return chars from file, starting from the position `o`. @@ -81,7 +80,6 @@ q)a[4+til 4] "ever" ``` - ## Fifo/named pipe Returns `n` characters from the pipe. @@ -96,11 +94,11 @@ q)read0(h;8) ``` ---- -:fontawesome-solid-book-open: -[Connection handles](../basics/handles.md), -[File system](../basics/files.md), -[Interprocess communication](../basics/ipc.md) + +[Connection handles](handles.md), +[File system](files.md),q4m +[Interprocess communication](../how_to/io_and_communication/ipc.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§11.4.1 Reading and Writing Text Files](/q4m3/11_IO/#1141-reading-and-writing-text-files) +[§11.4.1 Reading and Writing Text Files](../learn/q4m/11_IO.md/#1141-reading-and-writing-text-files) diff --git a/docs/ref/read1.md b/docs/ref/read1.md index 1f134bb9e..245d6398c 100644 --- a/docs/ref/read1.md +++ b/docs/ref/read1.md @@ -1,11 +1,11 @@ --- -title: read1 reads bytes | Reference | kdb+ and q documentation +title: read1 reads bytes | Reference | KDB-X and q documentation description: read1 is a q keyword that reads bytes from a file or named pipe -author: Stephen Taylor -keywords: bytes, file, filehandle, filesystem, handle, kdb+, pipe, process, q, read, read1 +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: bytes, file, filehandle, filesystem, handle, KDB-X, pipe, process, q, read, read1 --- -# :fontawesome-solid-database: `read1` +# `read1` _Read bytes from a file or named pipe_ @@ -19,21 +19,21 @@ read1 (fifo;n) read1[(fifo;n)] Where -- `f` is a [file symbol](../basics/glossary.md#file-symbol) -- `o` is an offset as a non-negative integer/long -- `h` is a [system or process handle](../basics/handles.md) -- `fifo` is a communication handle to a [Fifo](hopen.md#communication-handles) -- `n` is a length as a non-negative integer/long +- `f` is a [file symbol](glossary.md#file-symbol) +- `o` is an offset as a non-negative integer/long +- `h` is a [system or process handle](handles.md) +- `fifo` is a communication handle to a [Fifo](hopen.md#communication-handles) +- `n` is a length as a non-negative integer/long returns bytes from the source, as follows. ## File -Where the argument is +Where the argument is -- a file symbol. Returns the entire content of the file -- a file symbol and offset `(f;o)`. Returns the entire content of `f` from `o` onwards -- a file symbol, offset and length `(f;o;n)`. Returns up to `n` bytes from `f` starting at `o` +- a file symbol. Returns the entire content of the file +- a file symbol and offset `(f;o)`. Returns the entire content of `f` from `o` onwards +- a file symbol, offset and length `(f;o;n)`. Returns up to `n` bytes from `f` starting at `o` ```q q)`:test.txt 0:("hello";"goodbye") / write some text to a file @@ -63,8 +63,8 @@ q)read1`:file (Since V3.4.) Where `x` is -- a list `(fifo;length)`, returns `length` bytes read from `fifo` -- an integer atom `fifo`, blocks and returns bytes from `fifo` when EOF is encountered (`0#0x` if immediate) +- a list `(fifo;length)`, returns `length` bytes read from `fifo` +- an integer atom `fifo`, blocks and returns bytes from `fifo` when EOF is encountered (`0#0x` if immediate) ```q q)h:hopen`$":fifo:///etc/redhat-release" @@ -76,7 +76,6 @@ q)system"mkfifo somefifo";h:hopen`fifo:somefifo; 0N!read1 h; hclose h ``` ---- -:fontawesome-solid-book-open: -[File system](../basics/files.md), -[Interprocess communication](../basics/ipc.md) +[File system](files.md), +[Interprocess communication](../how_to/io_and_communication/ipc.md) diff --git a/docs/ref/reciprocal.md b/docs/ref/reciprocal.md index 2af39afbf..eef8e90d6 100644 --- a/docs/ref/reciprocal.md +++ b/docs/ref/reciprocal.md @@ -1,14 +1,11 @@ --- -title: reciprocal of a number | Reference | kdb+ and q documentation +title: reciprocal of a number | Reference | KDB-X and q documentation description: reciprocal is a q keyword that returns the reciprocal of a number. -author: Stephen Taylor -keywords: divide, division, divisor, kdb+, math, mathematics, numerator, q +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: divide, division, divisor, KDB-X, math, mathematics, numerator, q --- -# `reciprocal` - - - +# `reciprocal` _Reciprocal of a number_ @@ -25,11 +22,11 @@ q)reciprocal 1b 1f ``` -`reciprocal` is a [multithreaded primitive](../kb/mt-primitives.md). +`reciprocal` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`reciprocal` is an [atomic function](../basics/atomic.md). +`reciprocal` is an [atomic function](atomic.md). ```q q)reciprocal (12;13 14) @@ -57,7 +54,6 @@ def| 0.04761905 0.2 ghi| 0.3333333 0.1666667 ``` - ## Domain and range ```txt @@ -68,10 +64,9 @@ range f . f f f f f f f . p f f z f f f f Range: `fpz` ---- -:fontawesome-solid-book: -[`div`](div.md), -[Divide](divide.md) + +[`div`](div.md), +[Divide](divide.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) +[Mathematics](math.md) diff --git a/docs/ref/reverse.md b/docs/ref/reverse.md index eb2e4748c..1aeea6883 100644 --- a/docs/ref/reverse.md +++ b/docs/ref/reverse.md @@ -1,5 +1,5 @@ --- -title: reverse the order of items in a list or dictionary | Reference | kdb+ and q documentation +title: reverse the order of items in a list or dictionary | Reference | KDB-X and q documentation description: reverse is a q keyword that reverses the order of items in a list or dictionary. --- # `reverse` @@ -40,5 +40,5 @@ a b ``` ---- -:fontawesome-solid-book: + [`rotate`](rotate.md) \ No newline at end of file diff --git a/docs/ref/rotate.md b/docs/ref/rotate.md index eb4f9080c..48c75ed15 100644 --- a/docs/ref/rotate.md +++ b/docs/ref/rotate.md @@ -1,7 +1,7 @@ --- -title: rotate shifts the items of a list to the left or right | Reference | kdb+ and q documentation +title: rotate shifts the items of a list to the left or right | Reference | KDB-X and q documentation description: rotate is a q keyword that shifts the items of a list to the left or right. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `rotate` @@ -43,5 +43,5 @@ q)0 1 -1 rotate' 3 4#til 12 ---- -:fontawesome-solid-book: + [`reverse`](reverse.md) \ No newline at end of file diff --git a/docs/ref/save.md b/docs/ref/save.md index 97d11e36a..f3b638d99 100644 --- a/docs/ref/save.md +++ b/docs/ref/save.md @@ -1,13 +1,12 @@ --- -title: save, rsave keywords save tables to file | Reference | kdb+ and q documentation +title: save, rsave keywords save tables to file | Reference | KDB-X and q documentation description: save and rsave are q keywords that save global data to file or splayed to a directory. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- -# :fontawesome-solid-database: `save`, `rsave` - -_Write global data to file or splayed to a directory_ +# `save`, `rsave` +_Write global data to file or splayed to a directory_ ## `save` @@ -17,26 +16,24 @@ _Write a global variable to file and optionally format data_ save x save[x] ``` -Where `x` is a symbol atom or vector of the form `[path/to/]v[.ext]` in which - -- `v` is the name of a global variable -- `path/to/` is a file path (optional). If a file - - exists, it is overwritten - - does not exist, it is created, with any required parent directories -- `.ext` is a file extension (optional) which effects the file content format. Options are: - - `(none)` for binary format - - `csv` for comma-separated values - - `txt` for plain text) - - `xls` for Excel spreadsheet format - - `xml` for Extensible Markup Language (XML)) - - `json` for JavaScript Object Notation (JSON) Since v3.2 2014.07.31. +Where `x` is a symbol atom or vector of the form `[path/to/]v[.ext]` in which +- `v` is the name of a global variable +- `path/to/` is a file path (optional). If a file + - exists, it is overwritten + - does not exist, it is created, with any required parent directories +- `.ext` is a file extension (optional) which effects the file content format. Options are: + - `(none)` for binary format + - `csv` for comma-separated values + - `txt` for plain text) + - `xls` for Excel spreadsheet format + - `xml` for Extensible Markup Language (XML)) + - `json` for JavaScript Object Notation (JSON) Since v3.2 2014.07.31. writes global variable/s `v` etc. to file and returns the filename/s. !!! tip "There are no corresponding formats for [`load`](load.md). Instead, use [File Text](file-text.md)." -:fontawesome-regular-hand-point-right: [.h](doth.md) (data serialization tools) ### Examples @@ -92,8 +89,8 @@ q)save `a`b / multiple files Use [`set`](get.md) instead to save -- a variable to a file of a different name -- local data +- a variable to a file of a different name +- local data - ## `rsave` @@ -120,17 +116,17 @@ rsave x rsave[x] Where `x` is a table name as a symbol atom, saves the table, in binary format, splayed to a directory of the same name. The table must be fully enumerated and not keyed. -If the file - -- exists, it is overwritten -- does not exist, it is created, with any required parent directories +If the file +- exists, it is overwritten +- does not exist, it is created, with any required parent directories ### Limits !!! tip "The usual and more general way of doing this is to use [`set`](get.md#set), which allows the target directory to be specified." The following example uses the table `sp` created using the script [`sp.q`](https://raw.githubusercontent.com/KxSystems/kdb/master/sp.q) + ```q q)\l sp.q q)rsave `sp / save splayed table @@ -144,23 +140,20 @@ q)`:sp/ set sp / equivalent to rsave `sp `:sp/ ``` - ---- -:fontawesome-solid-book: -[`set`](get.md#set), + +[`set`](get.md#set), [`.h.tx`](doth.md#htx-filetypes), -[`.Q.dpft`](dotq.md#chk-fill-hdb) (save table), +[`.Q.dpft`](dotq.md#chk-fill-hdb) (save table), [`.Q.Xf`](dotq.md#xf-create-file) (create file)
-:fontawesome-solid-book-open: -[File system](../basics/files.md) -
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§11.2 Save and Load on Tables](/q4m3/11_IO/#112-save-and-load-on-tables) + +[File system](files.md)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§11.3 Splayed Tables](/q4m3/11_IO/#113-splayed-tables) +_Q for Mortals_q4m +[§11.2 Save and Load on Tables](../learn/q4m/11_IO.md/#112-save-and-load-on-tables) +
+_Q for Mortals_q4m +[§11.3 Splayed Tables](../learn/q4m/11_IO.md/#113-splayed-tables) diff --git a/docs/ref/select.md b/docs/ref/select.md index ea6bfa5aa..f549e3446 100644 --- a/docs/ref/select.md +++ b/docs/ref/select.md @@ -1,8 +1,8 @@ --- -title: select keyword, Select operator | Reference | kdb+ and q documentation +title: select keyword, Select operator | Reference | KDB-X and q documentation description: select and Select are (respectively) a q keyword and operator that select all or part of a table, possibly with new columns. -author: Stephen Taylor -keywords: column, kdb+, q, qsql, query, select, sql, table +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: column, KDB-X, q, qsql, query, select, sql, table --- # `select` @@ -15,8 +15,8 @@ _Select all or part of a table, possibly with new columns_ !!! info "`select` is a qSQL query template and varies from regular q syntax." For the Select operator `?`, see -:fontawesome-solid-book-open: -[Functional SQL](../basics/funsql.md) + +[Functional SQL](funsql.md) ## Syntax @@ -36,13 +36,13 @@ _t~exp~_ Table expression _p~w~_ Where phrase -:fontawesome-solid-book-open: -[qSQL syntax](../basics/qsql.md) + +[qSQL syntax](qsql.md) -The `select` query returns a table for both [call-by-name and call-by-value](../basics/qsql.md#from-phrase). +The `select` query returns a table for both [call-by-name and call-by-value](qsql.md#from-phrase). -Since 4.1t 2021.03.30, select from [partitioned tables](../kb/partition.md) maps relevant columns within each partition in parallel when running with [secondary threads](../basics/syscmds.md#s-number-of-secondary-threads). +Since 4.1t 2021.03.30, select from [partitioned tables](../how_to/interact_with_databases/partition.md) maps relevant columns within each partition in parallel when running with [secondary threads](syscmds.md#s-number-of-secondary-threads). ## Minimal form @@ -87,7 +87,7 @@ b 20 2.2 c 30 3.3 ``` -A [computed column](../basics/qsql.md#computed-columns) in the Select phrase cannot be referred to in another subphrase. +A [computed column](qsql.md#computed-columns) in the Select phrase cannot be referred to in another subphrase. ## Limit expression @@ -152,7 +152,7 @@ Unlike in SQL, columns in the By phrase - are included in the result and need not be specified in the Select phrase - can include computed columns -:fontawesome-solid-globe: + [The SQL `GROUP BY` statement](https://www.w3schools.com/sql/sql_groupby.asp) The [`ungroup`](ungroup.md) keyword reverses the grouping, though the original order is lost. @@ -209,20 +209,20 @@ Where there is a [By phrase](#by-phrase), and no sort order is specified, the re ## Cond [Cond](cond.md) is not supported inside query templates: -see [qSQL](../basics/qsql.md#cond). +see [qSQL](qsql.md#cond). ---- -:fontawesome-solid-book: + [`delete`](delete.md), [`exec`](exec.md), [`update`](update.md)
-:fontawesome-solid-book-open: -[qSQL](../basics/qsql.md), -[Functional SQL](../basics/funsql.md) + +[qSQL](qsql.md), +[Functional SQL](funsql.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.3 The `select` Template](/q4m3/9_Queries_q-sql/#93-the-select-template) +[§9.3 The `select` Template](../learn/q4m/9_Queries_q-sql.md/#93-the-select-template) diff --git a/docs/ref/set-attribute.md b/docs/ref/set-attribute.md index c985dceca..0b616fe5d 100644 --- a/docs/ref/set-attribute.md +++ b/docs/ref/set-attribute.md @@ -1,8 +1,8 @@ --- -title: Set Attribute | Reference | kdb+ and q documentation +title: Set Attribute | Reference | KDB-X and q documentation description: Set Attribute is a q operator that assigns an attribute to a list, dictionary or table. -author: Stephen Taylor -keywords: attribute, grouped, kdb+, parted, q, sorted, unique, +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: attribute, grouped, KDB-X, parted, q, sorted, unique, --- # `#` Set Attribute @@ -15,7 +15,7 @@ x#y #[x;y] Where `y` is a list or dictionary and atom `x` is -- an item from the list `` `s`u`p`g ``, returns `y` with the corresponding [attribute](../basics/syntax.md#attributes) set +- an item from the list `` `s`u`p`g ``, returns `y` with the corresponding [attribute](syntax.md#attributes) set - the null symbol `` ` ``, returns `y` with all attributes removed Attributes: @@ -85,7 +85,7 @@ The _unique_ attribute can be set on simple and mixed lists where all items are Attributes _parted_ and _grouped_ are useful for simple lists (where the datatype has an integral underlying value) in memory with a lot of repetition. The _parted_ attribute asserts all common values in the list are adjacent. -The _grouped_ attribute causes kdb+ to create and maintain an index (hash table). +The _grouped_ attribute causes KDB-X to create and maintain an index (hash table). If the data can be sorted such that `p` can be set, it effects better speedups than grouped, both on disk and in memory. @@ -124,7 +124,7 @@ u-fail not unique or not parted Some q functions use attributes to work faster: -- Where-clauses in [`select` and `exec` templates](../basics/qsql.md) run faster with `where =`, `where in` and `where within` +- Where-clauses in [`select` and `exec` templates](qsql.md) run faster with `where =`, `where in` and `where within` - Searching: [`bin`](bin.md), [`distinct`](distinct.md), [Find](find.md) and [`in`](in.md) (if the right argument has an attribute) - Sorting: [`iasc`](asc.md#iasc) and [`idesc`](desc.md#idesc) - Dictionaries: [`group`](group.md) @@ -134,13 +134,12 @@ Setting attributes consumes resources and is likely to improve performance only !!! warning "Applying an attribute to compressed data on disk decompresses it." ---- -:fontawesome-solid-book: + [`attr`](attr.md)
-:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) + +[Metadata](metadata.md)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§8.8 Attributes](/q4m3/8_Tables/#88-attributes) +_Q for Mortals_ +[§8.9 Attributes](../learn/q4m/8_Tables.md#89-attributes) diff --git a/docs/ref/show.md b/docs/ref/show.md index 69b4fa164..5ba80b475 100644 --- a/docs/ref/show.md +++ b/docs/ref/show.md @@ -1,8 +1,8 @@ --- -title: show – Reference – kdb+ and q documentation +title: show – Reference – KDB-X and q documentation description: show is a q keyword that formats its argument and displays it at the console. -author: Stephen Taylor -keywords: console, debug, develop, display, kdb+, q, tool +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: console, debug, develop, display, KDB-X, q, tool --- # `show` @@ -36,8 +36,8 @@ q)a~(::) ``` -:fontawesome-solid-book: + [Display](display.md)
-:fontawesome-solid-book-open: -[Debugging](../basics/debug.md) \ No newline at end of file + +[Debugging](../how_to/working-with-code/debug.md) \ No newline at end of file diff --git a/docs/ref/signal.md b/docs/ref/signal.md index 0098261e4..75fc6d189 100644 --- a/docs/ref/signal.md +++ b/docs/ref/signal.md @@ -1,7 +1,7 @@ --- -title: Signal | Reference | kdb+ and q documentation +title: Signal | Reference | KDB-X and q documentation description: Signal is a q operator that signals an error. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `'` Signal @@ -24,7 +24,7 @@ q)0N!0;'`err;0N!1 !!! info "Signal is part of q syntax. It is not an operator and cannot be iterated or projected." -:fontawesome-solid-book: + [`'` Quote overloads](overloads.md#quote) The only way to detect a signal is to use [Trap](apply.md#trap). @@ -79,7 +79,7 @@ During abort, the stack is unwound as far as the nearest [trap at](apply.md#trap 0 for sync message processing ``` -[`\e`](../basics/syscmds.md#e-error-trap-clients) sets the mode applied before async and HTTP callbacks run. Thus, `\e 1` will cause the relevant handlers to break into the debugger, while `\e 2` will dump the backtrace either to the server console (for async), or into the socket (for HTTP). +[`\e`](syscmds.md#e-error-trap-clients) sets the mode applied before async and HTTP callbacks run. Thus, `\e 1` will cause the relevant handlers to break into the debugger, while `\e 2` will dump the backtrace either to the server console (for async), or into the socket (for HTTP). ```q q)\e 2 q)'type / incoming async msg signals 'type @@ -108,7 +108,7 @@ q)f[] ^ q)g:{f[]} q)g[] -'bad +'badq4m [2] f:{'`bad} ^ [1] g:{f[]} @@ -154,14 +154,14 @@ q))a ``` ---- -:fontawesome-solid-book: + [Trap, Trap At](apply.md#trap)
-:fontawesome-solid-book-open: -[Controlling evaluation](../basics/control.md), -[Debugging](../basics/debug.md), -[Error handling](../basics/errors.md) + +[Controlling evaluation](control.md), +[Debugging](../how_to/working-with-code/debug.md), +[Error handling](errors.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§10.1.7 Return and Signal](/q4m3/10_Execution_Control/#1017-return-and-signal) +[§10.1.8 Return and Signal](../learn/q4m/10_Execution_Control.md#1018-return-and-signal) diff --git a/docs/ref/signum.md b/docs/ref/signum.md index 59b5319f7..6b0bfc594 100644 --- a/docs/ref/signum.md +++ b/docs/ref/signum.md @@ -1,22 +1,19 @@ --- -title: signum – the sign of a number | Reference | kdb+ and q documentation +title: signum – the sign of a number | Reference | KDB-X and q documentation description: signum is a q keyword that returns 1, 0,or -1 according to the sign of its argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `signum` - - - ```syntax signum x signum[x] ``` Where `x` (or its underlying value for temporals) is -- null or negative, returns `-1i` -- zero, returns `0i` -- positive, returns `1i` +- null or negative, returns `-1i` +- zero, returns `0i` +- positive, returns `1i` ```q q)signum -2 0 1 3 @@ -35,12 +32,11 @@ Find counts of price movements by direction: select count i by signum deltas price from trade ``` -`signum` is a [multithreaded primitive](../kb/mt-primitives.md). - +`signum` is a [multithreaded primitive](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`signum` is an [atomic function](../basics/atomic.md). +`signum` is an [atomic function](atomic.md). ```q q)signum(10;-20 30) @@ -68,7 +64,6 @@ def| -1 1 ghi| 1 -1 ``` - ## Domain and range ```txt @@ -79,8 +74,8 @@ range i . i i i i i i i . i i i i i i i i Range: `i` ---- -:fontawesome-solid-book: -[`abs`](abs.md) + +[`abs`](abs.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/simple-exec.md b/docs/ref/simple-exec.md index 064040493..abf492463 100644 --- a/docs/ref/simple-exec.md +++ b/docs/ref/simple-exec.md @@ -1,13 +1,13 @@ --- -title: Simple Exec – Reference – kdb+ and q documentation +title: Simple Exec – Reference – KDB-X and q documentation description: Simple Exec is a q operator that is part of functional SQL. -author: Stephen Taylor -keywords: functional sql, kdb+, q,sql +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: functional sql, KDB-X, q,sql --- # `?` Simple Exec -For functional Simple Exec, see Basics: [Functional qSQL](../basics/funsql.md#simple-exec) +For functional Simple Exec, see Basics: [Functional qSQL](funsql.md#simple-exec) diff --git a/docs/ref/sin.md b/docs/ref/sin.md index 170f1e0bd..90ab76cd7 100644 --- a/docs/ref/sin.md +++ b/docs/ref/sin.md @@ -1,22 +1,18 @@ --- -title: sin, asin – sine and arcsine | Reference | kdb+ and q documentation +title: sin, asin – sine and arcsine | Reference | KDB-X and q documentation description: sin and asin are q keywords that return (respectively) the sin and arcsine of their argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `sin`, `asin` _Sine, arcsine_ - - - - ```syntax sin x sin[x] asin x asin[x] ``` -Where `x` is a numeric, returns +Where `x` is a numeric, returns `sin` : the [sine](https://en.wikipedia.org/wiki/Sine) of `x`, taken to be in radians. The result is between `-1` and `1`, or null if the argument is null or infinity. @@ -35,12 +31,11 @@ q)asin 0.8 / arcsine 0.9272952 ``` -`sin` and `asin` are [multithreaded primitives](../kb/mt-primitives.md). - +`sin` and `asin` are [multithreaded primitives](mt-primitives.md). -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`sin` and `asin` are [atomic functions](../basics/atomic.md). +`sin` and `asin` are [atomic functions](atomic.md). ```q q)sin (.2;.3 .4) @@ -65,9 +60,8 @@ range: f . f f f f f f f . f f f z f f f f ``` ---- -:fontawesome-solid-book: + [`cos`, `acos`](cos.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) +[Mathematics](math.md) diff --git a/docs/ref/sqrt.md b/docs/ref/sqrt.md index be813a433..e1b63eb4c 100644 --- a/docs/ref/sqrt.md +++ b/docs/ref/sqrt.md @@ -1,13 +1,10 @@ --- -title: sqrt – square root | Reference | kdb+ and q documentation +title: sqrt – square root | Reference | KDB-X and q documentation description: sqrt is a q keyword that returns the square root of its argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `sqrt` - - - _Square root_ ```syntax @@ -16,10 +13,10 @@ sqrt x sqrt[x] Returns as a float where `x` is numeric and -- non-negative, the square root of `x` -- negative or null, null -- real or float infinity, `0w` -- any other infinity, the square root of the largest value for the datatype +- non-negative, the square root of `x` +- negative or null, null +- real or float infinity, `0w` +- any other infinity, the square root of the largest value for the datatype ```q q)sqrt -1 0n 0 25 50 @@ -35,12 +32,11 @@ q)sqrt 101b 1 0 1f ``` -`sqrt` is a [multithreaded primitive](../kb/mt-primitives.md). +`sqrt` is a [multithreaded primitive](mt-primitives.md). +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`sqrt` is an [atomic function](../basics/atomic.md). +`sqrt` is an [atomic function](atomic.md). ```q q)sqrt (10;20 30) @@ -78,11 +74,11 @@ range f . f f f f f f f . f f f z f f f f Range: `fz` ---- -:fontawesome-solid-book: -[`exp`](exp.md), -[`log`](log.md), -[`xexp`](exp.md#xexp), -[`xlog`](log.md#xlog) + +[`exp`](exp.md), +[`log`](log.md), +[`xexp`](exp.md#xexp), +[`xlog`](log.md#xlog)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/ss.md b/docs/ref/ss.md index af4a6ad83..3293f2281 100644 --- a/docs/ref/ss.md +++ b/docs/ref/ss.md @@ -1,7 +1,7 @@ --- -title: ss, ssr – string search and replacement | Reference | kdb+ and q documentation +title: ss, ssr – string search and replacement | Reference | KDB-X and q documentation description: ss and ssr are q keywords that perform string search and replacement. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `ss`, `ssr` @@ -21,7 +21,7 @@ x ss y ss[x;y] Where - `x` is a string -- `y` is a [pattern](../basics/regex.md) as a string (no asterisk) +- `y` is a [pattern](regex.md) as a string (no asterisk) returns an int vector of position/s within `x` of substrings that match pattern `y`. @@ -50,7 +50,7 @@ ssr[x;y;z] Where - `x` is a string -- `y` is a [pattern](../basics/regex.md) as a string (no asterisk) +- `y` is a [pattern](regex.md) as a string (no asterisk) - `z` is a string or a function returns `x` with each substring matching `y` replaced by: @@ -68,16 +68,16 @@ q)ssr[s;"t?r";upper] / replace matches by their uppercase ---- -:fontawesome-solid-book: + [`like`](like.md)
-:fontawesome-solid-book-open: -[Regular Expressions in q](../basics/regex.md) + +[Regular Expressions in q](regex.md)
-:fontawesome-solid-book-open: -[Strings](../basics/by-topic.md#strings) + +[Strings](by-topic.md#strings)
-:fontawesome-solid-graduation-cap: -[Using regular expressions](../basics/regex.md) + +[Using regular expressions](regex.md) diff --git a/docs/ref/string.md b/docs/ref/string.md index 948dc2f79..061692efd 100644 --- a/docs/ref/string.md +++ b/docs/ref/string.md @@ -1,15 +1,12 @@ --- -title: string casts its argument to a string | Reference | kdb+ and q documentation +title: string casts its argument to a string | Reference | KDB-X and q documentation description: string is a q keyword that casts its argument to a string. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `string` _Cast to string_ - - - ```syntax string x string[x] ``` @@ -27,10 +24,9 @@ q)string (+/) "+/" ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`string` is an [atomic function](../basics/atomic.md) and iterates through dictionaries and tables. +`string` is an [atomic function](atomic.md) and iterates through dictionaries and tables. ```q q)string (2 3;"abc") @@ -55,7 +51,6 @@ a b ,"3" "aapl" ``` - ## Domain and range ```txt @@ -66,17 +61,14 @@ range c c c c c c c c c c c c c c c c c c Range: `c` ---- -:fontawesome-solid-book:  + [`.h` namespace](doth.md)
-:fontawesome-solid-book:  + [`.Q.addr`](dotq.md#addr-iphost-as-int) (IP/host as int), [`.Q.f`](dotq.md#f-precision-format) (precision format), [`.Q.fmt`](dotq.md#fmt-precision-format) (precision format with length)
-:fontawesome-solid-street-view: -_Q for Mortals_ -[§7.3.1 Data to Strings](/q4m3/7_Transforming_Data/#731-data-to-strings) - - +_Q for Mortals_ +[§7.3.1 Data to Strings](../learn/q4m/7_Transforming_Data.md/#731-data-to-strings) diff --git a/docs/ref/sublist.md b/docs/ref/sublist.md index a25e9c4a3..154f196fa 100644 --- a/docs/ref/sublist.md +++ b/docs/ref/sublist.md @@ -1,7 +1,7 @@ --- -title: Sublist of a list | Reference | kdb+ and q documentation +title: Sublist of a list | Reference | KDB-X and q documentation description: sublist is a q keyword that returns a sublist of a list. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `sublist` @@ -72,9 +72,9 @@ q)1 2 sublist p / 2 items starting from position 1 ---- -:fontawesome-solid-book: + [Take](take.md)
-:fontawesome-solid-book-open: -[Selection](../basics/by-topic.md#selection) + +[Selection](by-topic.md#selection) diff --git a/docs/ref/subtract.md b/docs/ref/subtract.md index 7bb9e2970..240637f53 100644 --- a/docs/ref/subtract.md +++ b/docs/ref/subtract.md @@ -1,7 +1,7 @@ --- -title: Subtract | Reference | kdb+ and q documentation +title: Subtract | Reference | KDB-X and q documentation description: Subtract is a q operator that returns the difference of its arguments for a wide range of datatypes. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `-` Subtract @@ -21,12 +21,12 @@ q)2000.11.22 - 03:44:55.666 2000.11.21D20:15:04.334000000 ``` -`-` is a [multithreaded primitive](../kb/mt-primitives.md). +`-` is a [multithreaded primitive](mt-primitives.md). ## Implicit iteration -Subtract is an [atomic function](../basics/atomic.md). +Subtract is an [atomic function](atomic.md). ```q q)(10;20 30)-(2;3 4) @@ -34,7 +34,7 @@ q)(10;20 30)-(2;3 4) 17 26 ``` -It applies to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +It applies to [dictionaries and tables](math.md#dictionaries-and-tables). ```q q)k:`k xkey update k:`abc`def`ghi from t:flip d:`a`b!(10 -21 3;4 5 -6) @@ -69,7 +69,7 @@ ghi| 0 0 ## Range and domains The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt b g x h i j e f c s p m d z n u v t @@ -108,21 +108,21 @@ q)type 55-1i ``` ---- -:fontawesome-solid-book: + [Add](add.md), -[`deltas`](deltas.md), +[`deltas`](deltas.md),q4m [`differ`](differ.md), [`.Q.addmonths`](dotq.md#addmonths)
-:fontawesome-solid-book-open: -[Datatypes](../basics/datatypes.md), -[Mathematics](../basics/math.md) + +[Datatypes](datatypes.md), +[Mathematics](math.md)
-:fontawesome-solid-graduation-cap: -[How to handle temporal data in q](../kb/temporal-data.md) + +[How to handle temporal data in q](temporal-data.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.9.2 Temporal Arithmetic](/q4m3/4_Operators/#492-temporal-arithmetic) +[§4.9.2 Temporal Arithmetic](../learn/q4m/4_Operators.md/#492-temporal-arithmetic) diff --git a/docs/ref/sum.md b/docs/ref/sum.md index 541b79460..5374b4781 100644 --- a/docs/ref/sum.md +++ b/docs/ref/sum.md @@ -1,15 +1,12 @@ --- -title: sum, sums, msum, wsum – sum, cumulative sums, moving sums, and weighted sum of a list | Reference | kdb+ and q documentation +title: sum, sums, msum, wsum – sum, cumulative sums, moving sums, and weighted sum of a list | Reference | KDB-X and q documentation description: sum, sums, msum, and wsum are q keywords athat return (respectively) the sum, cumulative sums, moving sums, and weighted sum of their argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `sum`, `sums`, `msum`, `wsum` _Totals – simple, running, moving, and weighted_ - - - ## `sum` _Total_ @@ -20,10 +17,10 @@ sum x sum[x] Where `x` is -- a simple numeric list, returns the sums of its items -- an atom, returns `x` -- a list of numeric lists, returns their sums -- a dictionary with numeric values +- a simple numeric list, returns the sums of its items +- an atom, returns `x` +- a list of numeric lists, returns their sums +- a dictionary with numeric values Nulls are treated as zeros. @@ -63,8 +60,8 @@ q)sum each flip(0n 8;8 0n) /do this to fall back to vector case Different results may be obtained by changing the order of the summation. ❯ q -s 4 - KDB+ 4.0 2021.01.20 Copyright (C) 1993-2021 Kx Systems - m64/ 12()core 65536MB sjt mackenzie.local 127.0.0.1 .. + KDB-X 5.0.20251113 2025.11.13 Copyright (C) 1993-2025 Kx Systems + ... q)\s 0 q)a:100000000?1. @@ -80,7 +77,7 @@ q)sum each flip(0n 8;8 0n) /do this to fall back to vector case q)sum a 49999897.181933172 -`sum` is a [multithreaded primitive](../kb/mt-primitives.md). +`sum` is a [multithreaded primitive](mt-primitives.md). ## `sums` @@ -118,7 +115,6 @@ q)sums "abc" / type error if list is not numeric `sums` is a uniform function, equivalent to `+\`. - ## `msum` _Moving sums_ @@ -129,8 +125,8 @@ x msum y msum[x;y] Where -- `x` is a positive int atom -- `y` is a numeric list +- `x` is a positive int atom +- `y` is a numeric list returns the `x`-item moving sums of `y`, with nulls replaced by zero. The first `x` items of the result are the sums of the terms so far, and thereafter the result is the moving sum. @@ -143,7 +139,6 @@ q)3 msum 0N 2 3 5 0N 11 / nulls treated as zero `msum` is a uniform function. - ## `wsum` _Weighted sum_ @@ -152,7 +147,7 @@ _Weighted sum_ x wsum y wsum[x;y] ``` -Where `x` and `y` are numeric lists, returns the weighted sum of the products of `x` and `y`. When both `x` and `y` are integer lists, they are first converted to floats. +Where `x` and `y` are numeric lists, returns the weighted sum of the products of `x` and `y`. When both `x` and `y` are integer lists, they are first converted to floats. ```q q)2 3 4 wsum 1 2 4 / equivalent to sum 2 3 4 * 1 2 4f @@ -167,16 +162,14 @@ q)(1 2;3 4) wsum (500 400;300 200) `wsum` is an aggregate function, equivalent to `{sum x*y}`. -:fontawesome-solid-graduation-cap: -[Sliding windows](../kb/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window) +[Sliding windows](../examples/programming-idioms.md#how-do-i-apply-a-function-to-a-sequence-sliding-window)
-:fontawesome-brands-wikipedia-w: -[Weighted sum](https://en.wikipedia.org/wiki/Weight_function "Wikipedia") +[Weighted sum](https://en.wikipedia.org/wiki/Weight_function "Wikipedia") -## :fontawesome-solid-sitemap: Implicit iteration +## Implicit iteration -`sum`, `sums`, and `msum` apply to [dictionaries and tables](../basics/math.md#dictionaries-and-tables). +`sum`, `sums`, and `msum` apply to [dictionaries and tables](math.md#dictionaries-and-tables). `wsum` applies to dictionaries. ```q @@ -206,7 +199,6 @@ q)1 2 wsum d 18 31 15 ``` - ## Aggregating nulls `avg`, `min`, `max` and `sum` are special: they ignore nulls, in order to be similar to SQL92. @@ -217,16 +209,17 @@ q)sum (1 2;0N 4) 0N 6 ``` - ## Domains and ranges `sum` and `sums` + ```txt domain: b g x h i j e f c s p m d z n u v t range: i . i i i j e f i . p m d z n u v t ``` `msum` + ```txt b g x h i j e f c s p m d z n u v t ---------------------------------------- @@ -253,6 +246,7 @@ t | . . . . . . . . . . . . . . . . . . Range: `efijntuv` `wsum` + ```txt b g x h i j e f c s p m d z n u v t ---------------------------------------- @@ -278,9 +272,6 @@ t | t . t t t t t f t . . . . . . . . . Range: `defijmnptuvz` - - - ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/sv.md b/docs/ref/sv.md index 2ce3df3ae..0380f5b84 100644 --- a/docs/ref/sv.md +++ b/docs/ref/sv.md @@ -1,7 +1,7 @@ --- -title: sv – scalar from vector | Reference | kdb+ and q documentation +title: sv – scalar from vector | Reference | KDB-X and q documentation description: sv is a q keyword that performs a variety of functions under the general scheme of scalar (atom) from vector – join strings or filepath elements; decode a vector to an atom. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `sv` @@ -98,7 +98,7 @@ q)` sv `mywork`dat ``` -:fontawesome-solid-book: + [`vs`](vs.md#partition) partition @@ -188,14 +188,14 @@ q)0b sv 100011000110101110001011011001000110100000010101011000001000010000001010 8c6b8b64-6815-6084-0a3e-178401251b68 ``` -:fontawesome-solid-book: + [`vs`](vs.md#encode) encode
-:fontawesome-solid-book: + [`.Q.j10`](dotq.md#j10-encode-binhex) (encode binhex), [`.Q.x10`](dotq.md#x10-decode-binhex) (decode binhex)
-:fontawesome-solid-book: + [`.Q.j12`](dotq.md#j12-encode-base-36) (encode base36), [`.Q.x12`](dotq.md#x12-decode-base-36) (decode base36) diff --git a/docs/ref/system.md b/docs/ref/system.md index 49b00dcb6..d6bb906e6 100644 --- a/docs/ref/system.md +++ b/docs/ref/system.md @@ -1,11 +1,11 @@ --- -title: system keyword executes a system command | Reference | kdb+ and q documentation +title: system keyword executes a system command | Reference | KDB-X and q documentation description: system is a q keyword that executes a system command. -keywords: command, system, shell, os, kdb+, q -author: Stephen Taylor +keywords: command, system, shell, os, KDB-X, q +author: KX Systems, Inc., a subsidiary of KX Software Limited --- -# :fontawesome-solid-bullhorn: `system` +# `system` _Execute a system command_ @@ -13,11 +13,11 @@ _Execute a system command_ system x system[x] ``` -Where `x` is a string representing a [kdb+ system command](../basics/syscmds.md) or operating system shell command, and any parameters to it. Executes the command and returns the result as a list of character vectors. +Where `x` is a string representing a [KDB-X system command](syscmds.md) or operating system shell command, and any parameters to it. Executes the command and returns the result as a list of character vectors. -## kdb+ system commands +## KDB-X system commands -Refer to the [system commands reference](../basics/syscmds.md) for a full list of available commands. +Refer to the [system commands reference](syscmds.md) for a full list of available commands. !!! note "The system command does not include a leading `\`." @@ -34,7 +34,7 @@ q)count system "a" / this returns a result 3 ``` -### :fontawesome-brands-windows: Changing working directory +### Changing working directory In the event of an unexpected change to the working directory, Windows users please note @@ -49,16 +49,15 @@ q)system "pwd" !!! warning "Binary output" - The result is expected to be text, and is captured into a list of character vectors. - As part of this capture, line feeds and associated carriage returns are removed. - - This transformation makes it impractical to capture binary data from the result of the system call. - Redirecting the output to a - [file](https://code.kx.com/q/ref/read1/) or - [fifo](https://code.kx.com/q/kb/named-pipes/) for explicit ingestion may be appropriate in such cases. + The result is expected to be text, and is captured into a list of character vectors. + As part of this capture, line feeds and associated carriage returns are removed. + + This transformation makes it impractical to capture binary data from the result of the system call. + Redirecting the output to a + [file](read1.md) or + [fifo](../how_to/io_and_communication/named-pipes.md) for explicit ingestion may be appropriate in such cases. - -### :fontawesome-solid-database: Directing output to a file +### Directing output to a file When redirecting output to a file, for efficiency purposes, avoiding using `>tmpout` needlessly; append a semi-colon to the command. @@ -72,7 +71,7 @@ is essentially the same as the shell command cat x > tmpout ``` -as kdb+ tries to capture the output. +as KDB-X tries to capture the output. So if you do ```q @@ -97,7 +96,7 @@ the shell interpreter considers it as two statements cat x > y; > tmpout ``` -### :fontawesome-solid-triangle-exclamation: Capture stderr output +### Capture stderr output You cannot capture the stderr output from the system call directly, but a workaround is @@ -110,6 +109,3 @@ q)@[system;"ls egg";{0N!"error - ",x;}] ls: egg: No such file or directory "error - os" ``` - - - diff --git a/docs/ref/tables.md b/docs/ref/tables.md index 9ee121230..eb27d4c02 100644 --- a/docs/ref/tables.md +++ b/docs/ref/tables.md @@ -1,8 +1,8 @@ --- -title: tables – Reference – kdb+ and q documentation +title: tables – Reference – KDB-X and q documentation description: tables is a q keyword that returns a list of tables in a namespace. -author: Stephen Taylor -keywords: kdb+, metadata, q, table +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: KDB-X, metadata, q, table --- # `tables` @@ -29,5 +29,5 @@ q)tables `.work / tables in work ``` --- -:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) \ No newline at end of file + +[Metadata](metadata.md) \ No newline at end of file diff --git a/docs/ref/take.md b/docs/ref/take.md index 5ac4659b2..bc8701195 100644 --- a/docs/ref/take.md +++ b/docs/ref/take.md @@ -1,7 +1,7 @@ --- -title: Take selects leading or trailing items | Reference | kdb+ and q documentation +title: Take selects leading or trailing items | Reference | KDB-X and q documentation description: Take is a q operator that selects leading or trailing items from a list or dictionary, named entries from a dictionary, or named columns from a table. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `#` Take @@ -19,7 +19,7 @@ Where returns `y` as a list, dictionary or table described or selected by `x`. -`#` is a [multithreaded primitive](../kb/mt-primitives.md). +`#` is a [multithreaded primitive](mt-primitives.md). ## Atom or list @@ -278,9 +278,9 @@ s2| jones 10 paris ---- -:fontawesome-solid-street-view: + _Q for Mortals_ -[§8.4.5 Retrieving Multiple Records](/q4m3/8_Tables/#845-retrieving-multiple-records) +[§8.4.5 Retrieving Multiple Records](../learn/q4m/8_Tables.md/#845-retrieving-multiple-records) diff --git a/docs/ref/tan.md b/docs/ref/tan.md index a23a50544..c7c034f8d 100644 --- a/docs/ref/tan.md +++ b/docs/ref/tan.md @@ -1,21 +1,18 @@ --- -title: tan, atan – tangent and arctangent | Reference | kdb+ and q documentation +title: tan, atan – tangent and arctangent | Reference | KDB-X and q documentation description: tan and atan are q keywords that return the tangent or arctangent of their argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `tan`, `atan` - - _Tangent and arctangent_ - ```syntax tan x tan[x] atan x atan[x] ``` -Where `x` is a numeric, returns +Where `x` is a numeric, returns `tan` : the [tangent](https://en.wikipedia.org/wiki/Tangent) of `x`, taken to be in radians. Integer arguments are promoted to floating point. Null is returned if the argument is null or infinity. @@ -23,7 +20,7 @@ Where `x` is a numeric, returns : The function is equivalent to `{(sin x)%cos x}`. `atan` -: the [arctangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties) of `x`; that is, the value whose tangent is `x`. +: the [arctangent](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions#Basic_properties) of `x`; that is, the value whose tangent is `x`. : The result is in radians and lies between $-\frac{\pi}{2}$ and $\frac{\pi}{2}$. The range is approximate due to rounding errors. @@ -37,12 +34,11 @@ q)atan 42 1.546991 ``` -`tan` and `atan` are [multithreaded primitives](../kb/mt-primitives.md). +`tan` and `atan` are [multithreaded primitives](mt-primitives.md). +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`tan` and `atan` are [atomic functions](../basics/atomic.md). +`tan` and `atan` are [atomic functions](atomic.md). ```q q)tan (.2;.3 .4) @@ -59,7 +55,6 @@ y| 0.4227932 0.5463025 0.6841368 0.8422884 z| 1.029639 1.260158 1.557408 1.96476 ``` - ## Domain and range ```txt @@ -67,13 +62,10 @@ domain: b g x h i j e f c s p m d z n u v t range: f . f f f f f f f . f f f z f f f f ``` - ---- -:fontawesome-solid-book: [`cos` and `acos`](cos.md), [`sin` and `asin`](sin.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) +[Mathematics](math.md) diff --git a/docs/ref/til.md b/docs/ref/til.md index 464e09c97..55e1223f9 100644 --- a/docs/ref/til.md +++ b/docs/ref/til.md @@ -1,7 +1,7 @@ --- -title: til returns the first natural numbers | Reference | kdb+ and q documentation +title: til returns the first natural numbers | Reference | KDB-X and q documentation description: til is a q keyword that returns the natural numbers up to its argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `til` @@ -31,8 +31,8 @@ q)til 5f `til` and [`key`](key.md) are synonyms, but the above usage is conventionally reserved to `til`. -`til` is a [multithreaded primitive](../kb/mt-primitives.md). +`til` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md) diff --git a/docs/ref/tok.md b/docs/ref/tok.md index 3fd48edf3..0946c2089 100644 --- a/docs/ref/tok.md +++ b/docs/ref/tok.md @@ -1,7 +1,7 @@ --- -title: Tok interprets string data to another datatype | Reference | kdb+ and q documentation +title: Tok interprets string data to another datatype | Reference | KDB-X and q documentation description: Tok is a q operator that interprets string data to another datatype. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `$` Tok @@ -85,7 +85,7 @@ q)"D"$"2147483648" ## Iteration -Tok is a near-[atomic function](../basics/atomic.md). +Tok is a near-[atomic function](atomic.md). Implicit recursion stops at strings, not atoms. ```q @@ -155,7 +155,7 @@ q)"I"$"192.168.1.34" /an IP address as an int -1062731486i ``` -:fontawesome-solid-book: + [`.Q.addr`](dotq.md#addr-iphost-as-int) (IP/host as int), [`.Q.host`](dotq.md#host-ip-to-hostname) (IP to hostname) @@ -194,7 +194,6 @@ q)"PZ"$\:"20191122-11:11:11.123" 2019.11.22T11:11:11.123 ``` - ## Date formats `"D"$` will Tok dates with varied formats: @@ -207,26 +206,26 @@ yyyy/[mm|MMM]/dd dd/[mm|MMM]/[yy]yy / when \z is set to 1 ``` -:fontawesome-solid-book-open: -[Command-line option `-z` (date format)](../basics/cmdline.md#-z-date-format) + +[Command-line option `-z` (date format)](cmdline.md#-z-date-format)
-:fontawesome-solid-book-open: -[System command `\z` (date format)](../basics/syscmds.md#z-date-parsing) + +[System command `\z` (date format)](syscmds.md#z-date-parsing) ---- -:fontawesome-solid-book: + [Cast](cast.md)
-:fontawesome-solid-book: + [Overloads of `$`](overloads.md#dollar)
-:fontawesome-solid-book: + [`.h.iso8601`](doth.md#hiso8601-iso-timestamp) ISO 8601 timestamp
-:fontawesome-solid-book-open: -[Casting](../basics/by-topic.md#casting-and-encoding) + +[Casting](by-topic.md#casting-and-encoding)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§7.3.3 Parsing Data from Strings](/q4m3/7_Transforming_Data/#733-parsing-data-from-strings) +[§7.3.3 Parsing Data from Strings](../learn/q4m/7_Transforming_Data.md/#733-parsing-data-from-strings) diff --git a/docs/ref/trim.md b/docs/ref/trim.md index ed6a265d0..39417f89f 100644 --- a/docs/ref/trim.md +++ b/docs/ref/trim.md @@ -1,13 +1,12 @@ --- -title: trim, ltrim, rtrim – trim nulls from a list | Reference | kdb+ and q documentation +title: trim, ltrim, rtrim – trim nulls from a list | Reference | KDB-X and q documentation description: trim, ltrim, and rtrim are q keywords that remove leading or trailing spaces from a string. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `trim`, `ltrim`, `rtrim` _Remove leading or trailing nulls from a list_ - ```syntax trim x trim[x] ltrim x ltrim[x] @@ -34,10 +33,9 @@ q)trim 42 42 ``` +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`trim`, `ltrim`, and `rtrim` are [string-atomic](../basics/atomic.md#string-atomic) and apply to dictionaries and tables. +`trim`, `ltrim`, and `rtrim` are [string-atomic](atomic.md#string-atomic) and apply to dictionaries and tables. ```q q)trim(("fox";("jumps ";"over "));("a";"dog ")) @@ -55,7 +53,6 @@ a b ("jumps";"over") "dog" ``` - ## Domain and range ```txt @@ -64,9 +61,8 @@ range: b g x h i j e f c s p m d z n u v t ``` ---- -:fontawesome-solid-book: + [Drop](drop.md)
-:fontawesome-solid-book-open: -[Strings](../basics/by-topic.md#strings) +[Strings](by-topic.md#strings) diff --git a/docs/ref/type.md b/docs/ref/type.md index 7de2b05d8..6250f6050 100644 --- a/docs/ref/type.md +++ b/docs/ref/type.md @@ -1,7 +1,7 @@ --- -title: type – datatype of an object | Reference | kdb+ and q documentation +title: type – datatype of an object | Reference | KDB-X and q documentation description: type is a q keyword that returns as a short int the datatype of an object -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `type` @@ -15,7 +15,7 @@ _Type of an object_ type x type[x] ``` -Where `x` is any object, returns its [type](../basics/datatypes.md). +Where `x` is any object, returns its [type](datatypes.md). The type is a short int: @@ -42,12 +42,12 @@ q)type (0|+) / composition ---- -:fontawesome-solid-book: + [`key`](key.md#type-of-a-vector), [.Q.ty](dotq.md#ty-type)
-:fontawesome-solid-book-open: -[Casting and encoding](../basics/by-topic.md#casting-and-encoding), -[Datatypes](../basics/datatypes.md) + +[Casting and encoding](by-topic.md#casting-and-encoding), +[Datatypes](datatypes.md) diff --git a/docs/ref/uj.md b/docs/ref/uj.md index 5b4df10aa..bc567fd95 100644 --- a/docs/ref/uj.md +++ b/docs/ref/uj.md @@ -1,9 +1,9 @@ --- -title: uj – union join | Reference | kdb+ and q documentation +title: uj – union join | Reference | KDB-X and q documentation description: uj and ujf are q keywords that perform a union join on two tables. -keywords: join, kdb+, q, uj, ujf, union join +keywords: join, KDB-X, q, uj, ujf, union join --- -![Union join animation](../img/uj.gif) +![Union join animation](https://code.kx.com/q/img/uj.gif) {: style="float:right; margin-left: 3em; max-width: 250px;"} # `uj`, `ujf` @@ -58,7 +58,7 @@ a b| c d 3 7| 30 C ``` -`uj` is a [multithreaded primitive](../kb/mt-primitives.md). +`uj` is a [multithreaded primitive](mt-primitives.md). !!! note "`uj` generalizes the [`,` Join](join.md) operator." @@ -80,12 +80,12 @@ a b| c d -| --- 1| 1 2| z - q)x uj y / kdb+ 3.0 + q)x uj y / q 3.0 a| b c -| --- 1| 1 2| z - q)x uj y / kdb+ 2.8 + q)x uj y / q 2.8 a| b c -| ---- 1| x 1 @@ -96,10 +96,10 @@ a b| c d --- -:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.9.7 Union Join](/q4m3/9_Queries_q-sql/#997-union-join) +[§9.9.7 Union Join](../learn/q4m/9_Queries_q-sql.md/#997-union-join) diff --git a/docs/ref/ungroup.md b/docs/ref/ungroup.md index cd042a0f6..376dee0cd 100644 --- a/docs/ref/ungroup.md +++ b/docs/ref/ungroup.md @@ -1,7 +1,7 @@ --- -title: ungroup normalizes a table | Reference | kdb+ and q documentation +title: ungroup normalizes a table | Reference | KDB-X and q documentation description: ungroup is a q keyword that, where x is a table, in which some cells are lists, but for any row, all lists are of the same length, returns the normalized table, with one row for each item of a lists. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `ungroup` @@ -62,11 +62,11 @@ s4 p4 300 Grouping sorts on the keys, so a subsequent `ungroup` returns the original records sorted by the grouped column/s. ---- -:fontawesome-solid-book: + [`group`](group.md), [`select`](select.md), [`xgroup`](xgroup.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.3.4.2 Grouping without Aggregation](/q4m3/9_Queries_q-sql/#9342-grouping-without-aggregation) +[§9.3.4.2 Grouping without Aggregation](../learn/q4m/9_Queries_q-sql.md/#9342-grouping-without-aggregation) diff --git a/docs/ref/union.md b/docs/ref/union.md index 628f69449..3116de175 100644 --- a/docs/ref/union.md +++ b/docs/ref/union.md @@ -1,7 +1,7 @@ --- -title: union join of two tables | Reference | kdb+ and q documentation +title: union join of two tables | Reference | KDB-X and q documentation description: union is a q keyword that returns the union of two lists. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `union` @@ -38,10 +38,10 @@ q)(distinct t0,t1)~t0 union t1 ---- -:fontawesome-solid-book: + [`in`](in.md), [`inter`](inter.md), [`within`](within.md)
-:fontawesome-solid-book: -[Select](../basics/by-topic.md#selection) + +[Select](by-topic.md#selection) diff --git a/docs/ref/update.md b/docs/ref/update.md index c93a9a896..806fde346 100644 --- a/docs/ref/update.md +++ b/docs/ref/update.md @@ -1,8 +1,8 @@ --- -title: update keyword | Reference | kdb+ and q documentation +title: update keyword | Reference | KDB-X and q documentation description: update is a qSQL query template that adds rows or columns to a table. -author: Stephen Taylor -keywords: columns, kdb+, q, query, qsql, rows, sql, update +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: columns, KDB-X, q, query, qsql, rows, sql, update --- # `update` @@ -14,10 +14,10 @@ _Add or amend rows or columns of a table or entries in a dictionary_ !!! info "`update` is a qSQL query template and varies from regular q syntax." For the Update operator `!`, see -:fontawesome-solid-book-open: -[Functional SQL](../basics/funsql.md) -Since 4.1t 2021.06.04 updates from splayed table and path@tablename now leverage [peach](each.md) to load columns (when running with [secondary threads](../basics/syscmds.md#s-number-of-secondary-threads)). +[Functional SQL](funsql.md) + +Since 4.1t 2021.06.04 updates from splayed table and path@tablename now leverage [peach](each.md) to load columns (when running with [secondary threads](syscmds.md#s-number-of-secondary-threads)). ```q q)update x:0 from get`:mysplay ``` @@ -29,8 +29,8 @@ q)update x:0 from get`:mysplay update _p~s~_ [by _p~b~_] from _t~exp~_ [where _p~w~_] -:fontawesome-solid-book-open: -[qSQL query templates](../basics/qsql.md) + +[qSQL query templates](qsql.md) ## From phrase @@ -55,7 +55,7 @@ harry 35 green ## Where phrase -The [Where phrase](../basics/qsql.md#where-phrase) restricts the scope of updates. +The [Where phrase](qsql.md#where-phrase) restricts the scope of updates. ```q q)t:([] name:`tom`dick`harry; hair:`fair`dark`fair; eye:`green`brown`gray) @@ -125,20 +125,20 @@ Since 4.1 2024.04.29 throws `type` error if dictionary update contains by clause ## Cond Cond is not supported inside query templates: -see [qSQL](../basics/qsql.md#cond). +see [qSQL](qsql.md#cond). ---- -:fontawesome-solid-book: + [`delete`](delete.md), [`exec`](exec.md), [`select`](select.md)
-:fontawesome-solid-book-open: -[qSQL](../basics/qsql.md), -[Functional SQL](../basics/funsql.md) + +[qSQL](qsql.md), +[Functional SQL](funsql.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.5 The `update` template](/q4m3/9_Queries_q-sql/#95-the-update-template) +[§9.5 The `update` template](../learn/q4m/9_Queries_q-sql.md/#95-the-update-template) diff --git a/docs/ref/upsert.md b/docs/ref/upsert.md index 59d6002b1..5e7260a9b 100644 --- a/docs/ref/upsert.md +++ b/docs/ref/upsert.md @@ -1,7 +1,7 @@ --- -title: upsert | Reference | kdb+ and q documentation +title: upsert | Reference | KDB-X and q documentation description: upsert is a q keyword that adds new records to a table. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `upsert` @@ -158,15 +158,15 @@ Upserting to a splayed table appends new values to the column files. Enclose in a lambda or use [Vector Conditional](vector-conditional.md) instead. -:fontawesome-solid-book: + [`insert`](insert.md), [Join](join.md)
-:fontawesome-solid-book-open: -[Joins](../basics/joins.md), -[qSQL](../basics/qsql.md), -[Tables](../kb/faq.md) + +[Joins](joins.md), +[qSQL](qsql.md), +[Tables](faq.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.2 Upsert](/q4m3/9_Queries_q-sql/#92-upsert) \ No newline at end of file +[§9.2 Upsert](../learn/q4m/9_Queries_q-sql.md/#92-upsert) \ No newline at end of file diff --git a/docs/ref/value.md b/docs/ref/value.md index a12c5ab0c..e3bcce983 100644 --- a/docs/ref/value.md +++ b/docs/ref/value.md @@ -1,7 +1,7 @@ --- -title: value | Reference | kdb+ and q documentation +title: value | Reference | KDB-X and q documentation description: value is a q keyword that returns the value of a named variable, or metadata. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `value` @@ -184,7 +184,7 @@ q.test)value f ## Local values in suspended functions -See changes since V3.5 that support [debugging](../basics/debug.md#debugger). +See changes since V3.5 that support [debugging](../how_to/working-with-code/debug.md). ## `get` @@ -202,7 +202,7 @@ q)value each (get;value) / same internal code ---- -:fontawesome-solid-book: + [`eval`](eval.md), [`get`](get.md), [`parse`](parse.md), diff --git a/docs/ref/var.md b/docs/ref/var.md index 0571b8f06..62885c4c1 100644 --- a/docs/ref/var.md +++ b/docs/ref/var.md @@ -1,7 +1,7 @@ --- -title: var, svar – variance and sample variance | Reference | kdb+ and q documentation +title: var, svar – variance and sample variance | Reference | KDB-X and q documentation description: var and svar are q keywords that return (respectively) the variance and sample variance of their argument. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `var`, `svar` @@ -48,7 +48,7 @@ a| 1.555556 b| 4 ``` -`var` is a [multithreaded primitive](../kb/mt-primitives.md). +`var` is a [multithreaded primitive](mt-primitives.md). ## `svar` @@ -90,7 +90,7 @@ a| 2.333333 b| 8 ``` -`svar` is a [multithreaded primitive](../kb/mt-primitives.md). +`svar` is a [multithreaded primitive](mt-primitives.md). ## Domain and range @@ -103,16 +103,16 @@ range: f . f f f f f f f . f f f f f f f f ---- -:fontawesome-solid-book: + [`cov, scov`](cov.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) + +[Mathematics](math.md)
-:fontawesome-brands-wikipedia-w: + [Covariance](https://en.wikipedia.org/wiki/Covariance "Wikipedia"), [Variance](https://en.wikipedia.org/wiki/Variance "Wikipedia")
-:fontawesome-solid-globe: + [Variance](http://financereference.com/learn/variance "financereference.com") diff --git a/docs/ref/vector-conditional.md b/docs/ref/vector-conditional.md index 62edd06fd..f1be910bb 100644 --- a/docs/ref/vector-conditional.md +++ b/docs/ref/vector-conditional.md @@ -1,8 +1,8 @@ --- -title: Vector Conditional operator | Reference | kdb+ and q documentation +title: Vector Conditional operator | Reference | KDB-X and q documentation description: Vector Conditional is a q operator that replaces selected items of one list with corresponding items of another. -author: Stephen Taylor -keywords: condition, item, kdb+, q, vector +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: condition, item, KDB-X, q, vector --- # `?` Vector Conditional @@ -19,7 +19,7 @@ Where - `x` is a boolean vector - `y` and `z` are lists of the same type -- `x`, `y`, and `z` [conform](../basics/conformable.md) +- `x`, `y`, and `z` [conform](conformable.md) returns a new list by replacing elements of `y` with the elements of `z` when `x` is false. @@ -42,20 +42,20 @@ q)?[11001b;1 2 3 4 5;99] Since V2.7 2010.10.07 `?[x;y;z]` works for atoms too. -Vector Conditional can be used in [qSQL queries](../basics/qsql.md), which do not support [Cond](cond.md). +Vector Conditional can be used in [qSQL queries](qsql.md), which do not support [Cond](cond.md). -!!! tip "For multiple cases – more than just true/false – see [Controlling evaluation](../basics/control.md#case)." +!!! tip "For multiple cases – more than just true/false – see [Controlling evaluation](control.md#case)." ---- -:fontawesome-solid-book: + [`?` Query](overloads.md#query), [Cond](cond.md), [`if`](if.md)
-:fontawesome-solid-book-open: -[Controlling evaluation](../basics/control.md) + +[Controlling evaluation](control.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§10.1.3 Vector Conditional Evaluation](/q4m3/10_Execution_Control/#1013-vector-conditional-evaluation) +[§10.1.3 Vector Conditional Evaluation](../learn/q4m/10_Execution_Control.md/#1013-vector-conditional-evaluation) diff --git a/docs/ref/view.md b/docs/ref/view.md index e4924a7a0..2e5cb72d9 100644 --- a/docs/ref/view.md +++ b/docs/ref/view.md @@ -1,7 +1,7 @@ --- -title: view, views | Reference | kdb+ and q documentation +title: view, views | Reference | KDB-X and q documentation description: view and views are q keywords. view returns the expression defining a view. views lists views defined in the default namespace. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `view`, `views` @@ -48,12 +48,9 @@ q)views[] ``` --- -:fontawesome-solid-book-open: -[Metadata](../basics/metadata.md) -
-:fontawesome-solid-graduation-cap: -[Views](../learn/views.md) + +[Metadata](metadata.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§4.11 Alias](/q4m3/4_Operators/#411-alias) +[4.11 Views](../learn/q4m/4_Operators.md#411-views-advanced) diff --git a/docs/ref/vs.md b/docs/ref/vs.md index bddd5c39f..da3e81f63 100644 --- a/docs/ref/vs.md +++ b/docs/ref/vs.md @@ -1,8 +1,8 @@ --- -title: vs – Reference – kdb+ and q documentation +title: vs – Reference – KDB-X and q documentation description: vs is a q keyword that performs various functions under the scheme vector-from-scalar (atom). -author: Stephen Taylor -keywords: atom, decode, kdb+, keyword, q, scalar, vector, vs +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: atom, decode, KDB-X, keyword, q, scalar, vector, vs --- # `vs` @@ -96,7 +96,7 @@ q)` vs `:/home/kdb/data/mywork.dat `:/home/kdb/data`mywork.dat ``` -:fontawesome-solid-book: + [sv](sv.md#join) join @@ -202,14 +202,14 @@ q)10 vs(1995;1996 1997) ``` --- -:fontawesome-solid-book: + [`sv`](sv.md#decode) decode
-:fontawesome-solid-book: + [`.Q.j10`](dotq.md#j10-encode-binhex) encode binhex, [`.Q.j12`](dotq.md#j12-encode-base-36) encode base36
-:fontawesome-solid-book: + [`.Q.x10`](dotq.md#x10-decode-binhex) decode binhex, [`.Q.x12`](dotq.md#x12-decode-base-36) decode base36 diff --git a/docs/ref/where.md b/docs/ref/where.md index 303344b3b..b2f6b74fc 100644 --- a/docs/ref/where.md +++ b/docs/ref/where.md @@ -1,8 +1,8 @@ --- -title: where | Reference | kdb+ and q documentation +title: where | Reference | KDB-X and q documentation description: where is a q keyword that returns copies of indexes of a list or keys of a dictionary. -author: Stephen Taylor -keywords: kdb+, q, selection, where +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: KDB-X, q, selection, where --- # `where` @@ -64,8 +64,8 @@ q)where 0 1 2 3 ! 2 3 0 1 / same on dictionary with indices as keys ---- -:fontawesome-solid-book-open: -[`where` in q-SQL](../basics/qsql.md), -[Selection](../basics/by-topic.md#selection) + +[`where` in q-SQL](qsql.md), +[Selection](by-topic.md#selection) diff --git a/docs/ref/while.md b/docs/ref/while.md index d7c49b1d9..c3b95b41b 100644 --- a/docs/ref/while.md +++ b/docs/ref/while.md @@ -1,8 +1,8 @@ --- -title: while control word | Reference | kdb+ and q documentation +title: while control word | Reference | KDB-X and q documentation description: while is a q control word that governs iteration. -author: Stephen Taylor -keywords: condition, control, iteration, kdb+, q, while +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: condition, control, iteration, KDB-X, q, while --- # `while` @@ -42,14 +42,14 @@ The brackets of the expression list do not create lexical scope. Name scope within the brackets is the same as outside them. ---- -:fontawesome-solid-book: + [Accumulators – While](accumulators.md#while), [`do`](do.md), [`if`](if.md)
-:fontawesome-solid-book-open: -[Controlling evaluation](../basics/control.md) + +[Controlling evaluation](control.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§10.1.6 `while`](/q4m3/10_Execution_Control/#1016-while) +[10.1.7 `while`](../learn/q4m/10_Execution_Control.md#1017-while) \ No newline at end of file diff --git a/docs/ref/within.md b/docs/ref/within.md index 6a1073f0b..69f8c79e0 100644 --- a/docs/ref/within.md +++ b/docs/ref/within.md @@ -1,7 +1,7 @@ --- -title: within tests whether one argument is within the bounds defined by the other | Reference | kdb+ and q documentation +title: within tests whether one argument is within the bounds defined by the other | Reference | KDB-X and q documentation description: within is a q keyword that tests whether one argument is within the bounds defined by the other. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `within` @@ -47,17 +47,17 @@ q)(1 3 10 6 4;"acyxmpu") within ((2;"b");(6;"r")) `within` uses [Find](find.md) to search for `x` in `y`. -`within` is a [multithreaded primitive](../kb/mt-primitives.md). +`within` is a [multithreaded primitive](mt-primitives.md). ---- -:fontawesome-solid-book: + [`except`](except.md), [`in`](in.md), [`inter`](inter.md), [`union`](union.md)
-:fontawesome-solid-book-open: -[Search](../basics/by-topic.md#search) + +[Search](by-topic.md#search) diff --git a/docs/ref/wj.md b/docs/ref/wj.md index 081788b20..2542968cc 100644 --- a/docs/ref/wj.md +++ b/docs/ref/wj.md @@ -1,7 +1,7 @@ --- -title: Window join | Reference | kdb+ and q documentation +title: Window join | Reference | KDB-X and q documentation description: wj and wj1 are q keywords that perform window joins. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `wj`, `wj1` @@ -64,7 +64,7 @@ For `wj`, the prevailing quote on entry to the window is considered valid as quo | 3.0+ | `[]` | prevailing + `[]` | | 2.7/2.8 | `[)` | prevailing + `[]` | -:fontawesome-brands-wikipedia-w: + [Notation for intervals](https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals "Wikipedia") @@ -127,14 +127,14 @@ ibm 10:01:08 105 107 108 107 108 104 106 106 107 ---- -:fontawesome-solid-book: + [`aj`](aj.md), [`asof`](asof.md)
-:fontawesome-solid-book-open: -[Joins](../basics/joins.md) + +[Joins](joins.md)
-:fontawesome-solid-street-view: + _Q for Mortals_ -[§9.9.9 Window Joins](/q4m3/9_Queries_q-sql/#999-window-join) +[9.9.9 Window Joins](../learn/q4m/9_Queries_q-sql.md#999-window-joins) diff --git a/docs/ref/xbar.md b/docs/ref/xbar.md index 38319c2b6..c4ebcca0b 100644 --- a/docs/ref/xbar.md +++ b/docs/ref/xbar.md @@ -1,12 +1,10 @@ --- -title: xbar | Reference | kdb+ and q documentation +title: xbar | Reference | KDB-X and q documentation description: xbar is a q keyword that returns one argument rounded down to the nearest multiple of the other. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `xbar` - - _Round down_ ```syntax @@ -15,10 +13,10 @@ x xbar y xbar[x;y] Where -- `x` is a non-negative numeric atom -- `y` is numeric or temporal +- `x` is a non-negative numeric atom +- `y` is numeric or temporal -returns `y` rounded down to the nearest multiple of `x`. `xbar` is a [multithreaded primitive](../kb/mt-primitives.md). +returns `y` rounded down to the nearest multiple of `x`. `xbar` is a [multithreaded primitive](mt-primitives.md). ```q q)3 xbar til 16 @@ -82,16 +80,14 @@ q)-1+`date$3+3 xbar `month$2019.11.19 / end of that quarter 2019.12.31 ``` - !!! warning "Duplicate keys or column names" Duplicate keys in a dictionary or duplicate column names in a table will cause sorts and grades to return unpredictable results. +## Implicit iteration -## :fontawesome-solid-sitemap: Implicit iteration - -`xbar` is an [atomic function](../basics/atomic.md). -It applies to [dictionaries and keyed tables](../basics/math.md#dictionaries-and-tables) +`xbar` is an [atomic function](atomic.md). +It applies to [dictionaries and keyed tables](math.md#dictionaries-and-tables) ```q q)(3;4 5)xbar(10;20 -30) @@ -112,11 +108,10 @@ def| -21 3 ghi| 3 -6 ``` - ## Domain and range -The following shows the resulting output type given the input type of `x` and `y`. -The character representation of the datatypes referenced can be found [`here`](../basics/datatypes.md). +The following shows the resulting output type given the input type of `x` and `y`. +The character representation of the datatypes referenced can be found [`here`](datatypes.md). ```txt xbar| b g x h i j e f c s p m d z n u v t @@ -142,6 +137,7 @@ t | t . t t t t f f t . . . . . . . . . ``` For example, rounding down timespans to the nearest multiple of a long will produce a timespan. + ```q q)2 xbar 00:00:00.000000001 00:00:00.000000002 00:00:00.000000013 0D00:00:00.000000000 0D00:00:00.000000002 0D00:00:00.000000012 @@ -152,9 +148,8 @@ q)type 2 xbar 00:00:00.000000001 00:00:00.000000002 00:00:00.000000013 The possible range of output types are `ijfpmdznuvte`. ---- -:fontawesome-solid-book: + [`bin`](bin.md), [`floor`](floor.md)
-:fontawesome-solid-book-open: -[Mathematics](../basics/math.md) +[Mathematics](math.md) diff --git a/docs/ref/xgroup.md b/docs/ref/xgroup.md index 253f0ebfa..b6f9fa85c 100644 --- a/docs/ref/xgroup.md +++ b/docs/ref/xgroup.md @@ -1,8 +1,8 @@ --- -title: xgroup – Reference – kdb+ and q documentation +title: xgroup – Reference – KDB-X and q documentation description: xgroup is a q keyword that groups a table by values in selected columns. -author: Stephen Taylor -keywords: column, group, kdb+, q, xgroup +author: KX Systems, Inc., a subsidiary of KX Software Limited +keywords: column, group, KDB-X, q, xgroup --- # `xgroup` @@ -79,8 +79,8 @@ p3 s1 400 Duplicate keys in a dictionary or duplicate column names in a table will cause sorts and grades to return unpredictable results. -:fontawesome-solid-book: + [`group`](group.md)
-:fontawesome-solid-book-open: -[Dictionaries & tables](../basics/dictsandtables.md) + +[Dictionaries & tables](dictsandtables.md) diff --git a/docs/ref/xrank.md b/docs/ref/xrank.md index b7c7a3470..b3bd3f32c 100644 --- a/docs/ref/xrank.md +++ b/docs/ref/xrank.md @@ -1,7 +1,7 @@ --- -title: xrank – group by value | Reference | kdb+ and q documentation +title: xrank – group by value | Reference | KDB-X and q documentation description: xrank is a q keyword that groups its argument by value. -author: Stephen Taylor +author: KX Systems, Inc., a subsidiary of KX Software Limited --- # `xrank` @@ -67,5 +67,5 @@ bucket| Min Max Count ---- -:fontawesome-solid-book-open: -[Sorting](../basics/by-topic.md#sort) + +[Sorting](by-topic.md#sort) From 1a8ea9896d829769bb5f433049be2c8d370372d4 Mon Sep 17 00:00:00 2001 From: Tahir Salkic Date: Mon, 2 Mar 2026 09:20:54 -0500 Subject: [PATCH 2/2] Changed kdb-x to kdb+ --- docs/ref/abs.md | 2 +- docs/ref/accumulators.md | 4 +-- docs/ref/add.md | 4 +-- docs/ref/aj.md | 4 +-- docs/ref/all-any.md | 2 +- docs/ref/amend.md | 4 +-- docs/ref/apply.md | 4 +-- docs/ref/asc.md | 2 +- docs/ref/asof.md | 4 +-- docs/ref/assign.md | 2 +- docs/ref/attr.md | 2 +- docs/ref/avg.md | 2 +- docs/ref/bin.md | 4 +-- docs/ref/cast.md | 2 +- docs/ref/ceiling.md | 2 +- docs/ref/coalesce.md | 4 +-- docs/ref/cols.md | 2 +- docs/ref/compose.md | 4 +-- docs/ref/cond.md | 4 +-- docs/ref/cor.md | 2 +- docs/ref/cos.md | 2 +- docs/ref/count.md | 2 +- docs/ref/cov.md | 2 +- docs/ref/cross.md | 2 +- docs/ref/csv.md | 4 +-- docs/ref/cut.md | 4 +-- docs/ref/deal.md | 4 +-- docs/ref/delete.md | 4 +-- docs/ref/deltas.md | 4 +-- docs/ref/desc.md | 4 +-- docs/ref/dev.md | 2 +- docs/ref/dict.md | 4 +-- docs/ref/differ.md | 4 +-- docs/ref/display.md | 4 +-- docs/ref/distinct.md | 2 +- docs/ref/div.md | 4 +-- docs/ref/divide.md | 2 +- docs/ref/do.md | 4 +-- docs/ref/doth.md | 4 +-- docs/ref/dotj.md | 2 +- docs/ref/dotm.md | 4 +-- docs/ref/dotq.md | 16 +++++------ docs/ref/dotz.md | 50 +++++++++++++++++----------------- docs/ref/drop.md | 4 +-- docs/ref/dsave.md | 8 +++--- docs/ref/dynamic-load.md | 6 ++-- docs/ref/each.md | 2 +- docs/ref/ej.md | 4 +-- docs/ref/ema.md | 2 +- docs/ref/enkey.md | 4 +-- docs/ref/enlist.md | 2 +- docs/ref/enum-extend.md | 4 +-- docs/ref/enumerate.md | 2 +- docs/ref/enumeration.md | 4 +-- docs/ref/equal.md | 4 +-- docs/ref/eval.md | 2 +- docs/ref/except.md | 2 +- docs/ref/exec.md | 4 +-- docs/ref/exit.md | 8 +++--- docs/ref/exp.md | 2 +- docs/ref/fby.md | 4 +-- docs/ref/file-binary.md | 4 +-- docs/ref/file-text.md | 8 +++--- docs/ref/fill.md | 2 +- docs/ref/find.md | 4 +-- docs/ref/first.md | 4 +-- docs/ref/fkeys.md | 4 +-- docs/ref/flip-splayed.md | 6 ++-- docs/ref/flip.md | 2 +- docs/ref/floor.md | 4 +-- docs/ref/get.md | 12 ++++---- docs/ref/getenv.md | 2 +- docs/ref/greater-than.md | 4 +-- docs/ref/greater.md | 2 +- docs/ref/group.md | 2 +- docs/ref/gtime.md | 2 +- docs/ref/hcount.md | 2 +- docs/ref/hdel.md | 2 +- docs/ref/hopen.md | 4 +-- docs/ref/hsym.md | 2 +- docs/ref/identity.md | 2 +- docs/ref/if.md | 4 +-- docs/ref/ij.md | 4 +-- docs/ref/in.md | 2 +- docs/ref/index.md | 4 +-- docs/ref/insert.md | 2 +- docs/ref/inter.md | 4 +-- docs/ref/inv.md | 2 +- docs/ref/iterators.md | 2 +- docs/ref/join.md | 2 +- docs/ref/key.md | 4 +-- docs/ref/keys.md | 4 +-- docs/ref/less-than.md | 4 +-- docs/ref/lesser.md | 2 +- docs/ref/like.md | 2 +- docs/ref/lj.md | 4 +-- docs/ref/load.md | 6 ++-- docs/ref/log.md | 2 +- docs/ref/lower.md | 2 +- docs/ref/lsq.md | 2 +- docs/ref/maps.md | 6 ++-- docs/ref/match.md | 4 +-- docs/ref/max.md | 2 +- docs/ref/md5.md | 2 +- docs/ref/med.md | 4 +-- docs/ref/meta.md | 6 ++-- docs/ref/min.md | 2 +- docs/ref/mmu.md | 2 +- docs/ref/mod.md | 4 +-- docs/ref/multiply.md | 2 +- docs/ref/neg.md | 2 +- docs/ref/next.md | 2 +- docs/ref/not-equal.md | 4 +-- docs/ref/not.md | 4 +-- docs/ref/null.md | 2 +- docs/ref/or.md | 4 +-- docs/ref/over.md | 2 +- docs/ref/overloads.md | 2 +- docs/ref/pad.md | 2 +- docs/ref/parse.md | 2 +- docs/ref/pj.md | 4 +-- docs/ref/prd.md | 2 +- docs/ref/prior.md | 2 +- docs/ref/rand.md | 4 +-- docs/ref/rank.md | 2 +- docs/ref/ratios.md | 2 +- docs/ref/raze.md | 2 +- docs/ref/read0.md | 4 +-- docs/ref/read1.md | 4 +-- docs/ref/reciprocal.md | 4 +-- docs/ref/reverse.md | 2 +- docs/ref/rotate.md | 2 +- docs/ref/save.md | 2 +- docs/ref/select.md | 4 +-- docs/ref/set-attribute.md | 6 ++-- docs/ref/show.md | 4 +-- docs/ref/signal.md | 2 +- docs/ref/signum.md | 2 +- docs/ref/simple-exec.md | 4 +-- docs/ref/sin.md | 2 +- docs/ref/sqrt.md | 2 +- docs/ref/ss.md | 2 +- docs/ref/string.md | 2 +- docs/ref/sublist.md | 2 +- docs/ref/subtract.md | 2 +- docs/ref/sum.md | 4 +-- docs/ref/sv.md | 2 +- docs/ref/system.md | 10 +++---- docs/ref/tables.md | 4 +-- docs/ref/take.md | 2 +- docs/ref/tan.md | 2 +- docs/ref/til.md | 2 +- docs/ref/tok.md | 2 +- docs/ref/trim.md | 2 +- docs/ref/type.md | 2 +- docs/ref/uj.md | 4 +-- docs/ref/ungroup.md | 2 +- docs/ref/union.md | 2 +- docs/ref/update.md | 4 +-- docs/ref/upsert.md | 2 +- docs/ref/value.md | 2 +- docs/ref/var.md | 2 +- docs/ref/vector-conditional.md | 4 +-- docs/ref/view.md | 2 +- docs/ref/vs.md | 4 +-- docs/ref/where.md | 4 +-- docs/ref/while.md | 4 +-- docs/ref/within.md | 2 +- docs/ref/wj.md | 2 +- docs/ref/xbar.md | 2 +- docs/ref/xgroup.md | 4 +-- docs/ref/xrank.md | 2 +- 172 files changed, 302 insertions(+), 302 deletions(-) diff --git a/docs/ref/abs.md b/docs/ref/abs.md index 90e49c9f9..a69e4a117 100644 --- a/docs/ref/abs.md +++ b/docs/ref/abs.md @@ -1,5 +1,5 @@ --- -title: abs – absolute value | Reference | KDB-X and q documentation +title: abs – absolute value | Reference | kdb+ and q documentation description: abs is a q keyword that returns the absolute value of its argument author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/accumulators.md b/docs/ref/accumulators.md index c13d71192..733c8b3c7 100644 --- a/docs/ref/accumulators.md +++ b/docs/ref/accumulators.md @@ -1,8 +1,8 @@ --- -title: Accumulators – Reference – KDB-X and q documentation +title: Accumulators – Reference – kdb+ and q documentation description: An accumulator is an iterator that takes an applicable value as argument and derives a function that evaluates the value, first on its entire (first) argument, then on the results of successive evaluations. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: adverb, converge, dictionary, do, iterator, fold, KDB-X, keyword, map, map reduce, mnemonic, operator, over, q, scan, unary, value, while +keywords: adverb, converge, dictionary, do, iterator, fold, kdb+, keyword, map, map reduce, mnemonic, operator, over, q, scan, unary, value, while --- # Accumulators diff --git a/docs/ref/add.md b/docs/ref/add.md index da01a1649..c52556ee8 100644 --- a/docs/ref/add.md +++ b/docs/ref/add.md @@ -1,7 +1,7 @@ --- -title: Add | Reference | KDB-X and q documentation +title: Add | Reference | kdb+ and q documentation description: A q operator that returns the sum of two numeric, boolean or temporal arguments -keywords: add, KDB-X, mathematics, plus, q, sum +keywords: add, kdb+, mathematics, plus, q, sum --- # `+` Add diff --git a/docs/ref/aj.md b/docs/ref/aj.md index d17e91878..fb18a2eb3 100644 --- a/docs/ref/aj.md +++ b/docs/ref/aj.md @@ -1,7 +1,7 @@ --- -title: aj, aj0, ajf, ajf0 – as-of join | Reference | KDB-X and q documentation +title: aj, aj0, ajf, ajf0 – as-of join | Reference | kdb+ and q documentation description: As-of joins join two tables taking from the second the most recent records prior to the times in the first -keywords: as-of, join, KDB-X, q +keywords: as-of, join, kdb+, q --- # `aj`, `aj0`, `ajf`, `ajf0` diff --git a/docs/ref/all-any.md b/docs/ref/all-any.md index 69d1aaae2..2119f092c 100644 --- a/docs/ref/all-any.md +++ b/docs/ref/all-any.md @@ -1,5 +1,5 @@ --- -title: all, any – Reference – KDB-X and q documentation +title: all, any – Reference – kdb+ and q documentation description: all and any are q keywords that invoke aggregator functions for vectors of flags author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/amend.md b/docs/ref/amend.md index 3439f2e71..9d3ce035e 100644 --- a/docs/ref/amend.md +++ b/docs/ref/amend.md @@ -1,7 +1,7 @@ --- -title: Amend, Amend At – Reference – KDB-X and q documentation +title: Amend, Amend At – Reference – kdb+ and q documentation description: Operators Amend and Amend At modify one or more items in a list. -keywords: amend, amend at, at, dot, KDB-X, q +keywords: amend, amend at, at, dot, kdb+, q --- # `.` `@` Amend, Amend At diff --git a/docs/ref/apply.md b/docs/ref/apply.md index e8ff4b8da..ce6f4505f 100644 --- a/docs/ref/apply.md +++ b/docs/ref/apply.md @@ -1,8 +1,8 @@ --- -title: Apply (At), Index (At), Trap (At) | Reference | KDB-X and q documentation +title: Apply (At), Index (At), Trap (At) | Reference | kdb+ and q documentation description: Operators Apply (At), Index (At), and Trap (At) apply a function to one or more arguments, get items at depth in a list, and trap errors. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: apply, apply at, index, index at, KDB-X, q, trap, trap at +keywords: apply, apply at, index, index at, kdb+, q, trap, trap at --- [![Kandinsky: circles in a circle](https://code.kx.com/q/img/kandinsky-circles-in-a-circle.jpg)](https://en.wikipedia.org/wiki/Wassily_Kandinsky "Wikipedia") diff --git a/docs/ref/asc.md b/docs/ref/asc.md index afb01b1d9..4f73a1d00 100644 --- a/docs/ref/asc.md +++ b/docs/ref/asc.md @@ -1,5 +1,5 @@ --- -title: asc, iasc, xasc – ascending sort | Reference | KDB-X and q documentation +title: asc, iasc, xasc – ascending sort | Reference | kdb+ and q documentation description: Ascending sorts in q; asc returns a sortable argument in ascending order; iasc grades its items into ascending order; xasc sorts a table by columns. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/asof.md b/docs/ref/asof.md index 907e81887..de42590d4 100644 --- a/docs/ref/asof.md +++ b/docs/ref/asof.md @@ -1,7 +1,7 @@ --- -title: asof – Reference – KDB-X and q documentation +title: asof – Reference – kdb+ and q documentation description: Where t1 is a table and t2 is a table or dictionary in which the last key or column of t2 corresponds to a time column in t1, asof[t1;t2] returns the values from the last rows matching the rest of the keys and time ≤ the time in t2. -keywords: asof, join, KDB-X, q +keywords: asof, join, kdb+, q --- # `asof` diff --git a/docs/ref/assign.md b/docs/ref/assign.md index b938e3e26..407a56042 100644 --- a/docs/ref/assign.md +++ b/docs/ref/assign.md @@ -1,5 +1,5 @@ --- -title: Assign operator | Reference | KDB-X and q documentation +title: Assign operator | Reference | kdb+ and q documentation description: Name a value in q author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/attr.md b/docs/ref/attr.md index 44854be77..67c347194 100644 --- a/docs/ref/attr.md +++ b/docs/ref/attr.md @@ -1,5 +1,5 @@ --- -title: attr – attributes of an object | Reference | KDB-X and q documentation +title: attr – attributes of an object | Reference | kdb+ and q documentation description: attr is a q keyword that returns the attributes of an object author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/avg.md b/docs/ref/avg.md index c2f069c3c..6bb7cb93f 100644 --- a/docs/ref/avg.md +++ b/docs/ref/avg.md @@ -1,5 +1,5 @@ --- -title: avg, avgs, mavg, wavg – average, running average, moving averages, weighted average | Reference | KDB-X and q documentation +title: avg, avgs, mavg, wavg – average, running average, moving averages, weighted average | Reference | kdb+ and q documentation description: avg and wavg are q keywords invoking aggregate functions for the arithmetic and weighted means of a vector. avgs and mavgs are q keywords that invoke uniform functions that return the cumulative and moving means of a vector author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/bin.md b/docs/ref/bin.md index d12df703a..e0a1d3cad 100644 --- a/docs/ref/bin.md +++ b/docs/ref/bin.md @@ -1,7 +1,7 @@ --- -title: bin, binr | Reference | KDB-X and q documentation +title: bin, binr | Reference | kdb+ and q documentation description: bin and binr are q keywords that perform binary searches. -keywords: bin, binr, KDB-X, q, search, Find +keywords: bin, binr, kdb+, q, search, Find --- # `bin`, `binr` diff --git a/docs/ref/cast.md b/docs/ref/cast.md index e0d12f181..700f27567 100644 --- a/docs/ref/cast.md +++ b/docs/ref/cast.md @@ -1,5 +1,5 @@ --- -title: Cast converts data to another datatype | Reference | KDB-X and q documentation +title: Cast converts data to another datatype | Reference | kdb+ and q documentation description: Cast is a q operator that converts a data argument to another datatype. --- diff --git a/docs/ref/ceiling.md b/docs/ref/ceiling.md index 1843feb5e..ab6464c58 100644 --- a/docs/ref/ceiling.md +++ b/docs/ref/ceiling.md @@ -1,5 +1,5 @@ --- -title: ceiling | Reference | KDB-X and q documentation +title: ceiling | Reference | kdb+ and q documentation description: ceiling is a q keyword that returns the least integer greater than its numeric argument. --- # `ceiling` diff --git a/docs/ref/coalesce.md b/docs/ref/coalesce.md index 05829b2a5..5985d6bcb 100644 --- a/docs/ref/coalesce.md +++ b/docs/ref/coalesce.md @@ -1,7 +1,7 @@ --- -title: Coalesce operator | Reference | KDB-X and q documentation +title: Coalesce operator | Reference | kdb+ and q documentation description: Coalesce is a q operator that merges keyed tables. -keywords: coalesce, join, KDB-X,q +keywords: coalesce, join, kdb+,q --- # `^` Coalesce diff --git a/docs/ref/cols.md b/docs/ref/cols.md index ccb58f123..d01cb56aa 100644 --- a/docs/ref/cols.md +++ b/docs/ref/cols.md @@ -1,5 +1,5 @@ --- -title: cols, xcol, xcols | Reference | KDB-X and q documentation +title: cols, xcol, xcols | Reference | kdb+ and q documentation description: cols, xcol and xcols are q keywords. cols returns the column names of a table. xcol renames tablecolumns. xcols reorders table columns. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/compose.md b/docs/ref/compose.md index 2af4a7dd2..76fb5f31a 100644 --- a/docs/ref/compose.md +++ b/docs/ref/compose.md @@ -1,8 +1,8 @@ --- -title: Compose – compose functions together | Reference | KDB-X and q documentation +title: Compose – compose functions together | Reference | kdb+ and q documentation description: Compose is a q operator that composes (or curries) a unary value with another. The rank of the result is the rank of the second argument. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: adverb, compose, composition, function, KDB-X, map, q, value +keywords: adverb, compose, composition, function, kdb+, map, q, value --- # `'` Compose diff --git a/docs/ref/cond.md b/docs/ref/cond.md index d19f1211d..0fd0b1fab 100644 --- a/docs/ref/cond.md +++ b/docs/ref/cond.md @@ -1,8 +1,8 @@ --- -title: Cond | Reference | KDB-X and q documentation +title: Cond | Reference | kdb+ and q documentation description: Cond is a q control construct for conditional evaluation. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: cond, conditional, control, dollar, KDB-X, q +keywords: cond, conditional, control, dollar, kdb+, q --- # `$` Cond diff --git a/docs/ref/cor.md b/docs/ref/cor.md index 94ac201a9..f940dd48d 100644 --- a/docs/ref/cor.md +++ b/docs/ref/cor.md @@ -1,5 +1,5 @@ --- -title: cor – correlation coefficient | Reference | KDB-X and q documentation +title: cor – correlation coefficient | Reference | kdb+ and q documentation description: cor is a q keyword that calculates the correlation coefficient of two numeric lists. tags: correlation --- diff --git a/docs/ref/cos.md b/docs/ref/cos.md index 9ff7d65e1..f80ddf396 100644 --- a/docs/ref/cos.md +++ b/docs/ref/cos.md @@ -1,5 +1,5 @@ --- -title: cos, acos – cosine and arccosine | Reference | KDB-X and q documentation +title: cos, acos – cosine and arccosine | Reference | kdb+ and q documentation description: cos and acos are q keywords. They return the cosine and arccosine respectively of their numeric argument. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/count.md b/docs/ref/count.md index 116843d69..6a6d887ce 100644 --- a/docs/ref/count.md +++ b/docs/ref/count.md @@ -1,5 +1,5 @@ --- -title: Count the items of a list or dictionary | Reference | KDB-X and q documentation +title: Count the items of a list or dictionary | Reference | kdb+ and q documentation description: count and mcount are q keywords count returns the number of items in a list. mcount returns a moving count of the non-null items of a list. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/cov.md b/docs/ref/cov.md index af7592aaf..2b3085506 100644 --- a/docs/ref/cov.md +++ b/docs/ref/cov.md @@ -1,5 +1,5 @@ --- -title: covariance and sample covariance | Reference | KDB-X and q documentation +title: covariance and sample covariance | Reference | kdb+ and q documentation description: cov and scov are q keyword, that return respectively the covariance and sample covariance of two conforming numeric lists. --- # `cov`, `scov` diff --git a/docs/ref/cross.md b/docs/ref/cross.md index 4f9818ab8..2d48ed00e 100644 --- a/docs/ref/cross.md +++ b/docs/ref/cross.md @@ -1,5 +1,5 @@ --- -title: cross product | Reference | KDB-X and q documentation +title: cross product | Reference | kdb+ and q documentation description: cross is a q keyword that returns the cross-product (all possible combinations) of the items of its arguments. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/csv.md b/docs/ref/csv.md index 59ec05742..a9af595fe 100644 --- a/docs/ref/csv.md +++ b/docs/ref/csv.md @@ -1,8 +1,8 @@ --- -title: csv – Reference – KDB-X and q documentation +title: csv – Reference – kdb+ and q documentation description: csv is a q keyword that represents the delimiter of CSV files. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: comma, comma-separated values, csv, file, KDB-X, q, text +keywords: comma, comma-separated values, csv, file, kdb+, q, text --- # `csv` diff --git a/docs/ref/cut.md b/docs/ref/cut.md index 8e0ab1897..a4af4c22e 100644 --- a/docs/ref/cut.md +++ b/docs/ref/cut.md @@ -1,8 +1,8 @@ --- -title: Cut, cut – Reference – KDB-X and q documentation +title: Cut, cut – Reference – kdb+ and q documentation description: Cut is a q operator that cuts a list or table into subarrays. cut is a q keyword that cuts a list or table into a matrix into a specified number of columns. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: cut, KDB-X, keyword, operator, q +keywords: cut, kdb+, keyword, operator, q --- # `_` Cut, `cut` diff --git a/docs/ref/deal.md b/docs/ref/deal.md index 70759570b..74297022d 100644 --- a/docs/ref/deal.md +++ b/docs/ref/deal.md @@ -1,5 +1,5 @@ --- -title: Roll, Deal, Permute | Reference | KDB-X and q documentation +title: Roll, Deal, Permute | Reference | kdb+ and q documentation description: Roll, Deal, and Permute are q operators that return ran dom selections, with or without duplicates author: KX Systems, Inc., a subsidiary of KX Software Limited date: July 2019 @@ -170,7 +170,7 @@ q)0N?("the";1 2 4;`ibm`goog) / permute items ## Seed -Deal, Roll, Permute and [`rand`](rand.md) use a constant seed on KDB-X startup: scripts using them can be repeated with the same results. You can see and set the value of the seed with system command [`\S`](syscmds.md#s-random-seed).) +Deal, Roll, Permute and [`rand`](rand.md) use a constant seed on kdb+ startup: scripts using them can be repeated with the same results. You can see and set the value of the seed with system command [`\S`](syscmds.md#s-random-seed).) !!! tip "To use GUIDs as identifiers, use Deal, not Roll" diff --git a/docs/ref/delete.md b/docs/ref/delete.md index b55f0c937..df32259b9 100644 --- a/docs/ref/delete.md +++ b/docs/ref/delete.md @@ -1,8 +1,8 @@ --- -title: delete query | Reference | KDB-X and q documentation +title: delete query | Reference | kdb+ and q documentation description: delete is a qSQL template that removes rows or columns from a table, entries from a dictionary, or objects from a namespace. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: delete, functional KDB-X, q, query, qsql, sql +keywords: delete, functional kdb+, q, query, qsql, sql --- # `delete` diff --git a/docs/ref/deltas.md b/docs/ref/deltas.md index 73ee77d3d..e731ef441 100644 --- a/docs/ref/deltas.md +++ b/docs/ref/deltas.md @@ -1,7 +1,7 @@ --- -title: deltas – differences between adjacent list items | Reference | KDB-X and q documentation +title: deltas – differences between adjacent list items | Reference | kdb+ and q documentation description: deltas is a q keyword that returns the differences between adjacent list items. -keywords: diff, difference, item, KDB-X, list, q +keywords: diff, difference, item, kdb+, list, q --- # `deltas` diff --git a/docs/ref/desc.md b/docs/ref/desc.md index 0a698161e..a66490522 100644 --- a/docs/ref/desc.md +++ b/docs/ref/desc.md @@ -1,8 +1,8 @@ --- -title: desc, idesc, xdesc – descending sorts | Reference | KDB-X and q documentation +title: desc, idesc, xdesc – descending sorts | Reference | kdb+ and q documentation description: Descending sorts in q; desc returns a list sorted descending; idesc returns the grade for that sort. xdesc sorts a table descending by specified columns. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: asc, desc, descending, grade, idesc, KDB-X, q, sort, xdesc +keywords: asc, desc, descending, grade, idesc, kdb+, q, sort, xdesc --- # `desc`, `idesc`, `xdesc` diff --git a/docs/ref/dev.md b/docs/ref/dev.md index 79469efa3..c610fc64c 100644 --- a/docs/ref/dev.md +++ b/docs/ref/dev.md @@ -1,5 +1,5 @@ --- -title: dev, mdev, sdev – standard, moving, and sample standard deviations | Reference | KDB-X and q documentation +title: dev, mdev, sdev – standard, moving, and sample standard deviations | Reference | kdb+ and q documentation description: dev, mdev, and sdev are q keywords that return, respectively, the standard deviation, moving deviation, and sample standard deviation of their argument. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/dict.md b/docs/ref/dict.md index 73b90c387..df415bc51 100644 --- a/docs/ref/dict.md +++ b/docs/ref/dict.md @@ -1,8 +1,8 @@ --- -title: Dict | Reference | KDB-X and q documentation +title: Dict | Reference | kdb+ and q documentation description: Dict is a q operator that returns a dictionary from vectors of keys and values. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: bang, dict, dictionaries, dictionary, KDB-X, q +keywords: bang, dict, dictionaries, dictionary, kdb+, q --- # `!` Dict diff --git a/docs/ref/differ.md b/docs/ref/differ.md index c2dc4b78d..7549fc552 100644 --- a/docs/ref/differ.md +++ b/docs/ref/differ.md @@ -1,8 +1,8 @@ --- -title: differ – Reference – KDB-X and q documentation +title: differ – Reference – kdb+ and q documentation description: differ is a q keyword that flags where items of a list change value. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: diff, differ, KDB-X, item, list, q +keywords: diff, differ, kdb+, item, list, q --- # `differ` diff --git a/docs/ref/display.md b/docs/ref/display.md index bf553826d..9bcabf644 100644 --- a/docs/ref/display.md +++ b/docs/ref/display.md @@ -1,8 +1,8 @@ --- -title: Display – Reference – KDB-X and q documentation +title: Display – Reference – kdb+ and q documentation description: Display is a q operator that writes a value to the console before returning it. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: bang, console, debug, display, KDB-X +keywords: bang, console, debug, display, kdb+ --- # `!` Display diff --git a/docs/ref/distinct.md b/docs/ref/distinct.md index 2976666d8..f3ebc3990 100644 --- a/docs/ref/distinct.md +++ b/docs/ref/distinct.md @@ -1,5 +1,5 @@ --- -title: distinct – unique items of a list | Reference | KDB-X and q documentation +title: distinct – unique items of a list | Reference | kdb+ and q documentation description: distinct is a q keyword that returns the nub (the unique items) of a list. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/div.md b/docs/ref/div.md index f71daf549..baeffaeec 100644 --- a/docs/ref/div.md +++ b/docs/ref/div.md @@ -1,8 +1,8 @@ --- -title: div | Reference | KDB-X and q documentation +title: div | Reference | kdb+ and q documentation description: div is a q keyword that performs integer division. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: div, divide, division, in, integer, KDB-X, math, mathematics, q +keywords: div, divide, division, in, integer, kdb+, math, mathematics, q --- # `div` diff --git a/docs/ref/divide.md b/docs/ref/divide.md index e20e9d24d..68e5d5a02 100644 --- a/docs/ref/divide.md +++ b/docs/ref/divide.md @@ -1,5 +1,5 @@ --- -title: Divide | Reference | KDB-X and q documentation +title: Divide | Reference | kdb+ and q documentation description: Divide is a q operator that returns the ratio of its arguments. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/do.md b/docs/ref/do.md index 26ebe7806..b37338a17 100644 --- a/docs/ref/do.md +++ b/docs/ref/do.md @@ -1,8 +1,8 @@ --- -title: do control word | Reference | KDB-X and q documentation +title: do control word | Reference | kdb+ and q documentation description: do is a q control word that evaluates one or more expressions a set number of times. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: control, evaluate, expression, KDB-X, q +keywords: control, evaluate, expression, kdb+, q --- # `do` diff --git a/docs/ref/doth.md b/docs/ref/doth.md index 67f619bbe..c4b701b50 100644 --- a/docs/ref/doth.md +++ b/docs/ref/doth.md @@ -1,8 +1,8 @@ --- -title: The .h namespace | Reference | KDB-X and q documentation +title: The .h namespace | Reference | kdb+ and q documentation description: The .h namespace contains objects useful for marking up data for an HTTP response. author: KX Systems, Inc., a subsidiary of KX Software Limited -keywords: html, KDB-X, markup, q +keywords: html, kdb+, markup, q --- # The `.h` namespace diff --git a/docs/ref/dotj.md b/docs/ref/dotj.md index a2ef2dc8e..6b83fa86b 100644 --- a/docs/ref/dotj.md +++ b/docs/ref/dotj.md @@ -1,5 +1,5 @@ --- -title: The .j namespace – Reference – KDB-X and q documentation +title: The .j namespace – Reference – kdb+ and q documentation description: the .j namespace contains objects useful for converting between JSON and and q dictionaries. author: KX Systems, Inc., a subsidiary of KX Software Limited --- diff --git a/docs/ref/dotm.md b/docs/ref/dotm.md index d31374ec8..db9d5e8c9 100644 --- a/docs/ref/dotm.md +++ b/docs/ref/dotm.md @@ -1,6 +1,6 @@ --- -title: Memory backed by filesystem | Basics | q and KDB-X documentation -description: Memory can be backed by a filesystem, allowing use of DAX-enabled filesystems (e.g. AppDirect) as a non-persistent memory extension for KDB-X +title: Memory backed by filesystem | Basics | q and kdb+ documentation +description: Memory can be backed by a filesystem, allowing use of DAX-enabled filesystems (e.g. AppDirect) as a non-persistent memory extension for kdb+ author: KX Systems, Inc., a subsidiary of KX Software Limited date: November 2019 keywords: appdirect, dax, memory, thread diff --git a/docs/ref/dotq.md b/docs/ref/dotq.md index 40afb3d83..9059dd52a 100644 --- a/docs/ref/dotq.md +++ b/docs/ref/dotq.md @@ -1,5 +1,5 @@ --- -title: The .Q namespace – tools | Reference | KDB-X and q documentation +title: The .Q namespace – tools | Reference | kdb+ and q documentation description: The .Q namespace contains utility objects for q programming author: KX Systems, Inc., a subsidiary of KX Software Limited last_updated: January 2026 @@ -67,7 +67,7 @@ last_updated: January 2026 [Xf create file](#xf-create-file) -Functions defined in `q.k` are loaded as part of the ‘bootstrap’ of KDB-X. Some are exposed in the default namespace as the q language. Others are documented here as utility functions in the `.Q` [namespace](namespaces.md). +Functions defined in `q.k` are loaded as part of the ‘bootstrap’ of kdb+. Some are exposed in the default namespace as the q language. Others are documented here as utility functions in the `.Q` [namespace](namespaces.md). !!! warning "The `.Q` namespace is reserved for use by KX, as are all single-letter namespaces." @@ -875,7 +875,7 @@ Where (Since V3.4) -Reads `z`-sized lumps of complete `"\n"` delimited records from a pipe and applies a function to each record. This enables you to implement a streaming algorithm for various purposes such as converting a large compressed CSV file into an on-disk KDB-X database without holding the data in memory all at once or using disk space required for the uncompressed file. +Reads `z`-sized lumps of complete `"\n"` delimited records from a pipe and applies a function to each record. This enables you to implement a streaming algorithm for various purposes such as converting a large compressed CSV file into an on-disk kdb+ database without holding the data in memory all at once or using disk space required for the uncompressed file. [Streaming data from named pipes](../how_to/io_and_communication/named-pipes.md#stream-and-process-data-from-a-pipe) @@ -900,7 +900,7 @@ Where * `y` is a filepath * `z` is an integer -loops over file `y`, grabs `z`-sized lumps of complete `"\n"` delimited records, applies `x` to each record, and returns the size of the file as given by [`hcount`](hcount.md). This enables you to implement a streaming algorithm for various purposes such as converting a large CSV file into an on-disk KDB-X database without holding the data in memory all at once. +loops over file `y`, grabs `z`-sized lumps of complete `"\n"` delimited records, applies `x` to each record, and returns the size of the file as given by [`hcount`](hcount.md). This enables you to implement a streaming algorithm for various purposes such as converting a large CSV file into an on-disk kdb+ database without holding the data in memory all at once. `.Q.fsn` is almost identical to `.Q.fs` but takes an extra argument `z`, the size in bytes that chunks will be read in. This is particularly useful for balancing load speed and RAM usage. @@ -1588,7 +1588,7 @@ select … [by date,…] from … where [date …] !!! detail "You may need to increase the number of available file handles, and also the number of available file maps (for Linux see `vm.max_map_count`)" -Since 4.1t 2024.01.11 parallelized over tables and partitions with [peach](each.md) when KDB-X running with secondary threads. +Since 4.1t 2024.01.11 parallelized over tables and partitions with [peach](each.md) when kdb+ running with secondary threads.