kopia lustrzana https://github.com/miklobit/TiddlyWiki5
First batch of docs for the maths operators
rodzic
86387a9185
commit
7fcdc83bae
|
@ -1,7 +1,8 @@
|
|||
created: 20190206140446821
|
||||
modified: 20190206140446821
|
||||
title: Mathematics Operators
|
||||
modified: 20190611155838557
|
||||
tags: Filters
|
||||
title: Mathematics Operators
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">>The mathematics filter operators allow numerical calculations to be performed within filters.
|
||||
|
||||
|
@ -11,6 +12,8 @@ The mathematics operators interpret their arguments as numbers according to the
|
|||
* If the argument cannot be interpreted as a number, the value 0 is used (e.g. `foo` is interpreted as the number 0)
|
||||
* The special values `Infinity` and `-Infinity` can be used to represent positive and negative infinity respectively
|
||||
|
||||
<$macrocall $name=".warning" _="Some filter operators remove duplicate items which can cause unexpected results when using the mathematics operators. See [[Dominant Append]] for details."/>
|
||||
|
||||
The mathematics operators take three different forms:
|
||||
|
||||
* ''Unary operators'' apply an operation to each number in the input list (e.g. negate, truncate, sign)
|
||||
|
@ -20,7 +23,7 @@ The mathematics operators take three different forms:
|
|||
* ''Binary operators'' apply an operation and operand to each number in the input list (e.g. add, multiply, remainder)
|
||||
** <<.inline-operator-example "1 2 3 4 +[add[3]]">>
|
||||
** <<.inline-operator-example "1 2 3 4 +[multiply[8]]">>
|
||||
* ''Array operators'' apply an operation to all of the numbers in the input list, returning a single result (e.g. sum, product)
|
||||
* ''Reducing operators'' apply an operation to all of the numbers in the input list, returning a single result (e.g. sum, product)
|
||||
** <<.inline-operator-example "1 2 3 4 +[sum[]]">>
|
||||
** <<.inline-operator-example "1 2 3 4 +[product[]]">>
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
caption: add
|
||||
created: 20190206140446821
|
||||
modified: 20190206140446821
|
||||
modified: 20190611125053329
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, but with <<.place N>> added to each one
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, add to each the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: add Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
caption: add
|
||||
op-purpose: treating each input title as a number, add to each the numeric value of the operand
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-output: the input as numbers, but with <<.place N>> added to each one
|
||||
|
||||
<<.from-version "5.1.20">>
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "add">>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
caption: divide
|
||||
created: 20190611125839100
|
||||
modified: 20190611125922960
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, but with each one divided by <<.place N>>
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, divide them by the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: divide Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "divide">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611125225770
|
||||
modified: 20190611125525466
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: add Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]add[19]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[add[4]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611125929173
|
||||
modified: 20190611130146154
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: divide Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[355]divide[113]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[divide[2]]">>
|
|
@ -0,0 +1,9 @@
|
|||
created: 20190611154509136
|
||||
modified: 20190611154545304
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: exponential Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "123456789 +[exponential[4]]">>
|
||||
<<.operator-example 2 "123456789 +[exponential[13]]">>
|
||||
<<.operator-example 3 "1.23E23 +[exponential[90]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611150610846
|
||||
modified: 20190611150743047
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: fixed Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "10.123456789 +[fixed[5]]">>
|
||||
<<.operator-example 2 "[[355]divide[113]fixed[7]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611130905752
|
||||
modified: 20190611130938471
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: max Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]max[32]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[max[3]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611160949615
|
||||
modified: 20190611161010568
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: maxall Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "=1 =2 =3 =4 =5 +[maxall[]]">>
|
||||
<<.operator-example 2 "[tag[HelloThere]get[text]length[]maxall[]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611131138259
|
||||
modified: 20190611131149542
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: min Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]min[32]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[min[3]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611161051108
|
||||
modified: 20190611161107239
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: minall Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "=1 =2 =3 =4 =5 +[minall[]]">>
|
||||
<<.operator-example 2 "[tag[HelloThere]get[text]length[]minall[]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611125743568
|
||||
modified: 20190611125757767
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: multiply Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]multiply[19]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[multiply[4]]">>
|
|
@ -0,0 +1,9 @@
|
|||
created: 20190611151444751
|
||||
modified: 20190611154248537
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: precision Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "123456789 +[precision[3]]">>
|
||||
<<.operator-example 2 "123456789 +[precision[13]]">>
|
||||
<<.operator-example 3 "1.23E23 +[precision[90]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611160221390
|
||||
modified: 20190611160243829
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: product Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "=1 =2 =3 =4 =5 +[product[]]">>
|
||||
<<.operator-example 2 "[tag[HelloThere]get[text]length[]product[]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611130110805
|
||||
modified: 20190611130121033
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: remainder Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]remainder[3]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[remainder[2]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611125619962
|
||||
modified: 20190611125638512
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: subtract Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[[23]subtract[19]]">>
|
||||
<<.operator-example 2 "=1 =2 =3 =4 +[subtract[4]]">>
|
|
@ -0,0 +1,8 @@
|
|||
created: 20190611160000682
|
||||
modified: 20190611160139594
|
||||
tags: [[after Operator]] [[Operator Examples]]
|
||||
title: sum Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "=1 =2 =3 =4 =5 +[sum[]]">>
|
||||
<<.operator-example 2 "[tag[HelloThere]get[text]length[]sum[]]">>
|
|
@ -0,0 +1,17 @@
|
|||
caption: exponential
|
||||
created: 20190611154259136
|
||||
modified: 20190611154505880
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers converted to exponential notation with <<.place N>> digits
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: convert each number to exponential notation with <<.place N>> digits
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: exponential Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
The ''exponential'' operator returns a string representation of the input number in exponential notation with the specified number of digits. If a number has more digits than requested, the number is rounded to the nearest number represented by the specified number of digits
|
||||
|
||||
<<.operator-examples "exponential">>
|
|
@ -0,0 +1,17 @@
|
|||
caption: fixed
|
||||
created: 20190611150505495
|
||||
modified: 20190611150931872
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers converted to fixed point notation with <<.place N>> digits after the decimal point
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: convert each number to fixed point notation with <<.place N>> digits after the decimal point
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: fixed Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
The ''fixed'' operator returns a string representation of the input number that does not use exponential notation and has exactly the specified number of digits after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length.
|
||||
|
||||
<<.operator-examples "fixed">>
|
|
@ -0,0 +1,17 @@
|
|||
caption: max
|
||||
created: 20190611130631390
|
||||
modified: 20190611131047026
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, with any that are less than <<.place N>> being replaced by <<.place N>>
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, take the maximum of its value and the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: max Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
See also the [[min Operator]], and compare with the [[maxall Operator]] and the [[minall Operator]].
|
||||
|
||||
<<.operator-examples "max">>
|
|
@ -0,0 +1,15 @@
|
|||
caption: maxall
|
||||
created: 20190611160656499
|
||||
modified: 20190611160942704
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the largest of the input numbers
|
||||
op-purpose: find the largest of a list of numbers
|
||||
tags: [[Reducing Mathematics Operators]] [[Filter Operators]] [[Mathematics Operators]]
|
||||
title: maxall Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
See also the [[minall Operator]], and compare with the [[max Operator]] and the [[min Operator]].
|
||||
|
||||
<<.operator-examples "maxall">>
|
|
@ -0,0 +1,17 @@
|
|||
caption: min
|
||||
created: 20190611131102707
|
||||
modified: 20190611131135931
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, with any that are greater than <<.place N>> being replaced by <<.place N>>
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, take the minimum of its value and the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: min Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
See also the [[min Operator]], and compare with the [[maxall Operator]] and the [[minall Operator]].
|
||||
|
||||
<<.operator-examples "min">>
|
|
@ -0,0 +1,15 @@
|
|||
caption: minall
|
||||
created: 20190611161015153
|
||||
modified: 20190611161043817
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the smallest of the input numbers
|
||||
op-purpose: find the smallest of a list of numbers
|
||||
tags: [[Reducing Mathematics Operators]] [[Filter Operators]] [[Mathematics Operators]]
|
||||
title: minall Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
See also the [[maxall Operator]], and compare with the [[max Operator]] and the [[min Operator]].
|
||||
|
||||
<<.operator-examples "minall">>
|
|
@ -0,0 +1,15 @@
|
|||
caption: multiply
|
||||
created: 20190611125657820
|
||||
modified: 20190611125816555
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, but with each one multiplied by <<.place N>>
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, multiply it by the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: multiply Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "multiply">>
|
|
@ -0,0 +1,17 @@
|
|||
caption: precision
|
||||
created: 20190611150935800
|
||||
modified: 20190611151434569
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers with <<.place N>> significant digits
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: convert each number to a string with <<.place N>> significant digits
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: precision Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
The ''precision'' operator returns a string representation of the input number that has exactly the specified number of significant digits, using whichever is shorter of [[exponential|exponential Operator]] or [[fixed|fixed Operator]] notation.
|
||||
|
||||
<<.operator-examples "precision">>
|
|
@ -0,0 +1,13 @@
|
|||
caption: product
|
||||
created: 20190611160145434
|
||||
modified: 20190611160215653
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the result of multiplying together the input as numbers
|
||||
op-purpose: produce the product of the input numbers
|
||||
tags: [[Reducing Mathematics Operators]] [[Filter Operators]] [[Mathematics Operators]]
|
||||
title: product Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "product">>
|
|
@ -0,0 +1,15 @@
|
|||
caption: remainder
|
||||
created: 20190611130006275
|
||||
modified: 20190611130107195
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, but with each replaced by the remainder when dividing it by <<.place N>>
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, return the remainder when divided by the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: remainder Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "remainder">>
|
|
@ -0,0 +1,15 @@
|
|||
caption: subtract
|
||||
created: 20190611125542096
|
||||
modified: 20190611125616692
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the input as numbers, but with <<.place N>> subtracted from each one
|
||||
op-parameter: a number
|
||||
op-parameter-name: N
|
||||
op-purpose: treating each input title as a number, subtract from each the numeric value of the operand
|
||||
tags: [[Filter Operators]] [[Mathematics Operators]] [[Binary Mathematics Operators]]
|
||||
title: subtract Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "subtract">>
|
|
@ -0,0 +1,13 @@
|
|||
caption: sum
|
||||
created: 20190611155400623
|
||||
modified: 20190611155953322
|
||||
op-input: a [[selection of titles|Title Selection]]
|
||||
op-output: the result of adding together the input as numbers
|
||||
op-purpose: produce the sum of the input numbers
|
||||
tags: [[Reducing Mathematics Operators]] [[Filter Operators]] [[Mathematics Operators]]
|
||||
title: sum Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.20">> See [[Mathematics Operators]] for an overview.
|
||||
|
||||
<<.operator-examples "sum">>
|
Ładowanie…
Reference in New Issue