-: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 6d04447a..700f2756 100644
--- a/docs/ref/cast.md
+++ b/docs/ref/cast.md
@@ -5,8 +5,6 @@ description: Cast is a q operator that converts a data argument to another datat
# `$` 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 c4bd0815..ab6464c5 100644
--- a/docs/ref/ceiling.md
+++ b/docs/ref/ceiling.md
@@ -4,14 +4,13 @@ description: ceiling is a q keyword that returns the least integer greater than
---
# `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 ce1985cd..5985d6bc 100644
--- a/docs/ref/coalesce.md
+++ b/docs/ref/coalesce.md
@@ -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 41dd958e..d01cb56a 100644
--- a/docs/ref/cols.md
+++ b/docs/ref/cols.md
@@ -1,15 +1,12 @@
---
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: 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 c73249e8..76fb5f31 100644
--- a/docs/ref/compose.md
+++ b/docs/ref/compose.md
@@ -1,7 +1,7 @@
---
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: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: adverb, compose, composition, function, kdb+, 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 8177c07f..0fd0b1fa 100644
--- a/docs/ref/cond.md
+++ b/docs/ref/cond.md
@@ -1,7 +1,7 @@
---
title: Cond | Reference | kdb+ and q documentation
description: Cond is a q control construct for conditional evaluation.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: cond, conditional, control, dollar, kdb+, 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 66eb5733..f940dd48 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+ 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 cd280a86..f80ddf39 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
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 de56d3de..6a6d887c 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
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 81f6a034..2b308550 100644
--- a/docs/ref/cov.md
+++ b/docs/ref/cov.md
@@ -6,57 +6,54 @@ description: cov and scov are q keyword, that return respectively the covariance
_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 e0000c5a..2d48ed00 100644
--- a/docs/ref/cross.md
+++ b/docs/ref/cross.md
@@ -1,17 +1,17 @@
---
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: 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 96fb41b9..a9af595f 100644
--- a/docs/ref/csv.md
+++ b/docs/ref/csv.md
@@ -1,26 +1,22 @@
---
title: csv – Reference – kdb+ and q documentation
description: csv is a q keyword that represents the delimiter of CSV files.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: comma, comma-separated values, csv, file, kdb+, 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 412e5065..a4af4c22 100644
--- a/docs/ref/cut.md
+++ b/docs/ref/cut.md
@@ -1,15 +1,11 @@
---
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: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: cut, kdb+, 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 5c28dc23..74297022 100644
--- a/docs/ref/deal.md
+++ b/docs/ref/deal.md
@@ -1,7 +1,7 @@
---
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: 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+ 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 cb505a8c..df32259b 100644
--- a/docs/ref/delete.md
+++ b/docs/ref/delete.md
@@ -1,7 +1,7 @@
---
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: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: delete, functional kdb+, 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 9d1f1730..e731ef44 100644
--- a/docs/ref/deltas.md
+++ b/docs/ref/deltas.md
@@ -7,48 +7,66 @@ keywords: diff, difference, item, kdb+, list, q
_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 5d176cfa..a6649052 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
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
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: asc, desc, descending, grade, idesc, kdb+, 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 3467f77f..c610fc64 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
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 734874ba..df415bc5 100644
--- a/docs/ref/dict.md
+++ b/docs/ref/dict.md
@@ -1,7 +1,7 @@
---
title: Dict | Reference | kdb+ and q documentation
description: Dict is a q operator that returns a dictionary from vectors of keys and values.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: bang, dict, dictionaries, dictionary, kdb+, 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 67b7f151..7549fc55 100644
--- a/docs/ref/differ.md
+++ b/docs/ref/differ.md
@@ -1,65 +1,67 @@
---
title: differ – Reference – kdb+ and q documentation
description: differ is a q keyword that flags where items of a list change value.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: diff, differ, kdb+, 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 7560fba9..9bcabf64 100644
--- a/docs/ref/display.md
+++ b/docs/ref/display.md
@@ -1,7 +1,7 @@
---
title: Display – Reference – kdb+ and q documentation
description: Display is a q operator that writes a value to the console before returning it.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: bang, console, debug, display, kdb+
---
# `!` 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 25e018ac..f3ebc399 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
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 a2f98939..baeffaee 100644
--- a/docs/ref/div.md
+++ b/docs/ref/div.md
@@ -1,14 +1,11 @@
---
title: div | Reference | kdb+ and q documentation
description: div is a q keyword that performs integer division.
-author: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: div, divide, division, in, integer, kdb+, 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 fee3f1db..68e5d5a0 100644
--- a/docs/ref/divide.md
+++ b/docs/ref/divide.md
@@ -1,14 +1,10 @@
---
title: Divide | Reference | kdb+ 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 e35f5357..b37338a1 100644
--- a/docs/ref/do.md
+++ b/docs/ref/do.md
@@ -1,7 +1,7 @@
---
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: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: control, evaluate, expression, kdb+, 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 ad156755..c4b701b5 100644
--- a/docs/ref/doth.md
+++ b/docs/ref/doth.md
@@ -1,16 +1,13 @@
---
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: Stephen Taylor
+author: KX Systems, Inc., a subsidiary of KX Software Limited
keywords: html, kdb+, 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)
"