diff --git a/docs/architecture/tickq.md b/docs/architecture/tickq.md index 95da9fa4..93348ee5 100644 --- a/docs/architecture/tickq.md +++ b/docs/architecture/tickq.md @@ -127,7 +127,7 @@ Actions performed: * increment current date ([`.u.d`](#variables)) to next day * roll log if using tickerplant log, i.e. * close current tickerplant log ([`.u.l`](#variables)) - * create a new tickerplant log file i.e set [`.u.l`](#variables), call [`.u.ld`](#uld) with new date + * create a new tickerplant log file i.e. set [`.u.l`](#variables), call [`.u.ld`](#uld) with new date ### .u.tick @@ -165,7 +165,7 @@ Where `x` is current date. Returns handle of log file for that date. Actions performed: -* using [`.u.L`](#variables), change last 10 chars to provided date and create log file if it doesnt yet exist +* using [`.u.L`](#variables), change last 10 chars to provided date and create log file if it does not yet exist * set [`.u.i`](#variables) and [`.u.j`](#variables) to count of valid messages currently in log file * if log file is found to be corrupt (size bigger than size of number of valid messages) an error is returned * open new/existing log file diff --git a/docs/basics/glossary.md b/docs/basics/glossary.md index 8e24454e..60739656 100644 --- a/docs/basics/glossary.md +++ b/docs/basics/glossary.md @@ -48,7 +48,7 @@ The terminology generalizes to values. - The left domain of a matrix `m` is `til count m`. - The right domain of a matrix is `til count first m`. -- The right domains of a list `m` of depth `n` are `1_n{til count first x}\m`. +- The right domains of a list `m` of depth `n` are `1_til each count each (n-1)first\m`. The single argument of a unary function is sometimes referred to as its _right argument_. @@ -431,7 +431,9 @@ Q knows the identity elements of some functions, e.g. `+` (zero), but not others ## Infix Applying an operator by writing it between its arguments, e.g. -`2+3` applies `+` to 2 and 3 +`2+3` applies `+` to 2 and 3. + +The alternative in most cases is to apply an operator prefix, e.g. `+[2;3]`. ## Item, list item @@ -592,12 +594,16 @@ Files representing a [splayed table](#splayed-table) may also be partitioned. ## Postfix -Applying an iterator to its argument by writing it to the right, e.g. `+/` applies iterator `/` to `+`. (Not to be confused with projecting an operator on its left argument.) +Postfix notation is when a function is written to the right of its arguments. Only iterators can be written postfix, +e.g. `+/` applies iterator `/` to `+`. (Not to be confused with projecting an operator on its left argument, +e.g. `+[1 2 3]` is a projection of the `+` operator, while `+/[1 2 3]` is a reduction of `+` over the list `1 2 3`.) +:fontawesome-solid-book: +[Iterators](../ref/iterators.md) ## Prefix -Prefix notation applies a unary value `v` to its argument or indices `x`; i.e. `vx` is equivalent to `v[x]`. +Prefix notation applies a unary value `v` to its argument or indices `x`; i.e. `v x` is equivalent to `v[x]`. :fontawesome-regular-hand-point-right: [Application](application.md) @@ -820,7 +826,7 @@ A value of rank 1, i.e. a function with 1 argument, or a list of depth ≥1. ## Unary operator -See **Iterator**. +An operator with only 1 argument. Iterators are unary operators. :fontawesome-solid-book: [Iterators](../ref/iterators.md) diff --git a/docs/ref/accumulators.md b/docs/ref/accumulators.md index 99caef1b..80e95214 100644 --- a/docs/ref/accumulators.md +++ b/docs/ref/accumulators.md @@ -131,6 +131,8 @@ Matching is governed by [comparison tolerance](../basics/precision.md#comparison ### Do +In its binary form, with an integer `n≥0` as the left argument, the derived function is applied `n` times. + ```q q)dbl:2* q)3 dbl\2 7 / Do @@ -188,6 +190,9 @@ q)("j"$a=b) foo/bar / ?[a=b;foo bar;bar] ### While +In its binary form, if the left argument `t` of the derived function is an applicable unary value, +it is applied **while** `t` applied on the result returns true or something other than `0`. + ```q q)(10>)dbl\2 / While 2 4 8 16 diff --git a/docs/ref/and.md b/docs/ref/and.md index 9840275f..8f1579c7 100644 --- a/docs/ref/and.md +++ b/docs/ref/and.md @@ -6,9 +6,25 @@ author: Stephen Taylor # `and` - _Lesser of two values, logical AND_ +```syntax +x and y and[x;y] +x & y &[x;y] +``` + +Returns the [lesser](../basics/comparison.md) of the underlying values of `x` and `y`. +In the case of boolean values, it is equivalent to the AND operator. + +```q +q)2 and 3 +2 +q)1010b and 1100b /logical AND with booleans +1000b +q)"sat" and "cow" +"cat" +``` + `and` is a [multithreaded primitive](../kb/mt-primitives.md). :fontawesome-solid-book: diff --git a/docs/ref/get.md b/docs/ref/get.md index a6fa20e6..1e094906 100644 --- a/docs/ref/get.md +++ b/docs/ref/get.md @@ -51,10 +51,17 @@ q)s:get`:SNewTrade/ / s has columns mapped on demand 5 q)get "2+3" 5 + q)a:1 2 3 + q)get `a + 1 2 3 + q)get `q`w`e!(1 2;3 4;5 6) + 1 2 + 3 4 + 5 6 + q)get (+;1;2) + 3 ``` - - [`eval`](eval.md), [`value`](value.md) diff --git a/docs/ref/or.md b/docs/ref/or.md index 6bba0531..2c6fac6c 100644 --- a/docs/ref/or.md +++ b/docs/ref/or.md @@ -8,11 +8,26 @@ keywords: and, greater, kdb+, logic, or, q _Greater of two values, logical OR_ -`or` is a [multithreaded primitive](../kb/mt-primitives.md). +```syntax +x or y or[x;y] +x | y |[x;y] +``` + +Returns the [greater](../basics/comparison.md) of the underlying values of `x` and `y`. +In the case of boolean values, it is equivalent to the OR operator. +```q +q)2 or 3 +3 +q)1010b or 1100b /logical OR with booleans +1110b +q)"sat" or "cow" +"sow" +``` +`or` is a [multithreaded primitive](../kb/mt-primitives.md). - +:fontawesome-solid-book: [Greater](greater.md) diff --git a/docs/wp/disaster-floods/index.md b/docs/wp/disaster-floods/index.md index bf402726..9c4223dd 100644 --- a/docs/wp/disaster-floods/index.md +++ b/docs/wp/disaster-floods/index.md @@ -1257,9 +1257,9 @@ I gratefully acknowledge the Disaster Prevention team at FDL: Piotr Bilinski, Ch ### 1. Kd-tree -A kd-tree is used in k-dimensional space to create a tree structure. In the tree each node represents a hyperplane which divides the space into two seperate parts (the left and the right branch) based on a given direction. This direction is associated with a certain axis dimension, with the hyperplane perpendicular to the axis dimension. What is to the left or right of the hyperplane is determined by whether each data point being added to the tree is greater or less than the node value at the splitting dimension. For example, if the splitting dimension of the node is `x`, all data points with a smaller `x` value than the value at the splitting dimension node will be to the left of the hyperplane, while all points equal to or greater than will be in the right subplane. +A kd-tree is used in k-dimensional space to create a tree structure. In the tree each node represents a hyperplane which divides the space into two separate parts (the left and the right branch) based on a given direction. This direction is associated with a certain axis dimension, with the hyperplane perpendicular to the axis dimension. What is to the left or right of the hyperplane is determined by whether each data point being added to the tree is greater or less than the node value at the splitting dimension. For example, if the splitting dimension of the node is `x`, all data points with a smaller `x` value than the value at the splitting dimension node will be to the left of the hyperplane, while all points equal to or greater than will be in the right subplane. -The tree is used to efficiently find a datapoint’s nearest neighbor, by potentially eleminating a large portion of the dataset using the kd-tree’s properties. This is done by starting at the root and moving down the tree recursively, calculating the distance between each node and the datapoint in question, allowing branches of the dataset to be eliminated based on whether this node-point distance is less than or greater than the curent nearest neighbor distance. This enables rapid lookups for each point in a dataset. +The tree is used to efficiently find a datapoint’s nearest neighbor, by potentially eliminating a large portion of the dataset using the kd-tree’s properties. This is done by starting at the root and moving down the tree recursively, calculating the distance between each node and the datapoint in question, allowing branches of the dataset to be eliminated based on whether this node-point distance is less than or greater than the current nearest neighbor distance. This enables rapid lookups for each point in a dataset. ![Figure_10](imgs/KDtree.png)
diff --git a/docs/wp/disaster-recovery/index.md b/docs/wp/disaster-recovery/index.md index 7d80b681..83192610 100644 --- a/docs/wp/disaster-recovery/index.md +++ b/docs/wp/disaster-recovery/index.md @@ -432,7 +432,7 @@ This is usually due to a column vector being a different length from the rest of the table. The only method to fix it is to count each column file and compare, then manually saving the erroneous one to the correct length. This can occur when not using -the standard save commands (.e.g [`.Q.dpft`](../../ref/dotq.md#dpft-save-table)), but rather setting each +the standard save commands (e.g. [`.Q.dpft`](../../ref/dotq.md#dpft-save-table)), but rather setting each column individually, and some logic has caused the column lengths to vary. diff --git a/docs/wp/hdb-analysis/index.md b/docs/wp/hdb-analysis/index.md index 8938d758..f92d940b 100644 --- a/docs/wp/hdb-analysis/index.md +++ b/docs/wp/hdb-analysis/index.md @@ -825,4 +825,4 @@ Analysis levels 7 and 8 are the most time consuming, for this reason, the defaul Some ideas for improvements: * run `paths`,`dotd` etc once on startup and store the results for lookup rather than regenerating at each step. -* recovery mode if loading the hdb fails; if there is an issue with the latest partition, the hdb can fail to load. Most of the hdb variables in the `.Q` namespace (.e.g. `.Q.pv`) could be constructed on load error. However, as so much is dependent on the structure of the latest partition, it may be better to leave this to be manually investigated and fixed first. +* recovery mode if loading the hdb fails; if there is an issue with the latest partition, the hdb can fail to load. Most of the hdb variables in the `.Q` namespace (e.g. `.Q.pv`) could be constructed on load error. However, as so much is dependent on the structure of the latest partition, it may be better to leave this to be manually investigated and fixed first.