Skip to content

Commit ef6ee4d

Browse files
authored
Merge pull request #447 from rhidra/minor_changes
Improve iterators descriptions + fix pending FIXME flags + typos and consistency issues
2 parents 5a95321 + 47c02ba commit ef6ee4d

9 files changed

Lines changed: 65 additions & 16 deletions

File tree

docs/architecture/tickq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Actions performed:
127127
* increment current date ([`.u.d`](#variables)) to next day
128128
* roll log if using tickerplant log, i.e.
129129
* close current tickerplant log ([`.u.l`](#variables))
130-
* create a new tickerplant log file i.e set [`.u.l`](#variables), call [`.u.ld`](#uld) with new date
130+
* create a new tickerplant log file i.e. set [`.u.l`](#variables), call [`.u.ld`](#uld) with new date
131131

132132
### .u.tick
133133

@@ -165,7 +165,7 @@ Where `x` is current date. Returns handle of log file for that date.
165165

166166
Actions performed:
167167

168-
* using [`.u.L`](#variables), change last 10 chars to provided date and create log file if it doesnt yet exist
168+
* using [`.u.L`](#variables), change last 10 chars to provided date and create log file if it does not yet exist
169169
* set [`.u.i`](#variables) and [`.u.j`](#variables) to count of valid messages currently in log file
170170
* if log file is found to be corrupt (size bigger than size of number of valid messages) an error is returned
171171
* open new/existing log file

docs/basics/glossary.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The terminology generalizes to values.
4848

4949
- The left domain of a matrix `m` is `til count m`.
5050
- The right domain of a matrix is `til count first m`.
51-
- The right domains of a list `m` of depth `n` are `1_n{til count first x}\m`. <!-- FIXME Check -->
51+
- The right domains of a list `m` of depth `n` are `1_til each count each (n-1)first\m`.
5252

5353
The single argument of a unary function is sometimes referred to as its _right argument_.
5454

@@ -431,7 +431,9 @@ Q knows the identity elements of some functions, e.g. `+` (zero), but not others
431431
## Infix
432432

433433
Applying an operator by writing it between its arguments, e.g.
434-
`2+3` applies `+` to 2 and 3
434+
`2+3` applies `+` to 2 and 3.
435+
436+
The alternative in most cases is to apply an operator prefix, e.g. `+[2;3]`.
435437

436438

437439
## Item, list item
@@ -592,12 +594,16 @@ Files representing a [splayed table](#splayed-table) may also be partitioned.
592594

593595
## Postfix
594596

595-
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.)
597+
Postfix notation is when a function is written to the right of its arguments. Only iterators can be written postfix,
598+
e.g. `+/` applies iterator `/` to `+`. (Not to be confused with projecting an operator on its left argument,
599+
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`.)
596600

601+
:fontawesome-solid-book:
602+
[Iterators](../ref/iterators.md)
597603

598604
## Prefix
599605

600-
Prefix notation applies a unary value `v` to its argument or indices `x`; i.e. `vx` is equivalent to `v[x]`.
606+
Prefix notation applies a unary value `v` to its argument or indices `x`; i.e. `v x` is equivalent to `v[x]`.
601607

602608
:fontawesome-regular-hand-point-right:
603609
[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.
820826

821827
## Unary operator
822828

823-
See **Iterator**.
829+
An operator with only 1 argument. Iterators are unary operators.
824830

825831
:fontawesome-solid-book:
826832
[Iterators](../ref/iterators.md)

docs/ref/accumulators.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ Matching is governed by [comparison tolerance](../basics/precision.md#comparison
131131

132132
### Do
133133

134+
In its binary form, with an integer `n≥0` as the left argument, the derived function is applied `n` times.
135+
134136
```q
135137
q)dbl:2*
136138
q)3 dbl\2 7 / Do
@@ -188,6 +190,9 @@ q)("j"$a=b) foo/bar / ?[a=b;foo bar;bar]
188190

189191
### While
190192

193+
In its binary form, if the left argument `t` of the derived function is an applicable unary value,
194+
it is applied **while** `t` applied on the result returns true or something other than `0`.
195+
191196
```q
192197
q)(10>)dbl\2 / While
193198
2 4 8 16

docs/ref/and.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,25 @@ author: Stephen Taylor
66

77
# `and`
88

9-
109
_Lesser of two values, logical AND_
1110

11+
```syntax
12+
x and y and[x;y]
13+
x & y &[x;y]
14+
```
15+
16+
Returns the [lesser](../basics/comparison.md) of the underlying values of `x` and `y`.
17+
In the case of boolean values, it is equivalent to the AND operator.
18+
19+
```q
20+
q)2 and 3
21+
2
22+
q)1010b and 1100b /logical AND with booleans
23+
1000b
24+
q)"sat" and "cow"
25+
"cat"
26+
```
27+
1228
`and` is a [multithreaded primitive](../kb/mt-primitives.md).
1329

1430
:fontawesome-solid-book:

docs/ref/get.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ q)s:get`:SNewTrade/ / s has columns mapped on demand
5151
5
5252
q)get "2+3"
5353
5
54+
q)a:1 2 3
55+
q)get `a
56+
1 2 3
57+
q)get `q`w`e!(1 2;3 4;5 6)
58+
1 2
59+
3 4
60+
5 6
61+
q)get (+;1;2)
62+
3
5463
```
5564

56-
<!-- FIXME: describe other uses. -->
57-
5865
[`eval`](eval.md),
5966
[`value`](value.md)
6067

docs/ref/or.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@ keywords: and, greater, kdb+, logic, or, q
88

99
_Greater of two values, logical OR_
1010

11-
`or` is a [multithreaded primitive](../kb/mt-primitives.md).
11+
```syntax
12+
x or y or[x;y]
13+
x | y |[x;y]
14+
```
15+
16+
Returns the [greater](../basics/comparison.md) of the underlying values of `x` and `y`.
17+
In the case of boolean values, it is equivalent to the OR operator.
1218

19+
```q
20+
q)2 or 3
21+
3
22+
q)1010b or 1100b /logical OR with booleans
23+
1110b
24+
q)"sat" or "cow"
25+
"sow"
26+
```
1327

28+
`or` is a [multithreaded primitive](../kb/mt-primitives.md).
1429

15-
30+
:fontawesome-solid-book:
1631
[Greater](greater.md)
1732

1833

docs/wp/disaster-floods/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,9 +1257,9 @@ I gratefully acknowledge the Disaster Prevention team at FDL: Piotr Bilinski, Ch
12571257

12581258
### 1. Kd-tree
12591259

1260-
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.
1260+
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.
12611261

1262-
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.
1262+
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.
12631263

12641264

12651265
![Figure_10](imgs/KDtree.png)<br/>

docs/wp/disaster-recovery/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ This is usually due to a column vector being a different
432432
length from the rest of the table. The only method to fix it is to
433433
count each column file and compare, then manually saving the
434434
erroneous one to the correct length. This can occur when not using
435-
the standard save commands (.e.g [`.Q.dpft`](../../ref/dotq.md#dpft-save-table)), but rather setting each
435+
the standard save commands (e.g. [`.Q.dpft`](../../ref/dotq.md#dpft-save-table)), but rather setting each
436436
column individually, and some logic has caused the column lengths to
437437
vary.
438438

docs/wp/hdb-analysis/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,4 +825,4 @@ Analysis levels 7 and 8 are the most time consuming, for this reason, the defaul
825825
Some ideas for improvements:
826826

827827
* run `paths`,`dotd` etc once on startup and store the results for lookup rather than regenerating at each step.
828-
* 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.
828+
* 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.

0 commit comments

Comments
 (0)