From 1e867ac3ef3f48beea20747d997ee115440b5fc3 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Sat, 5 Oct 2019 20:37:17 -0400 Subject: [PATCH 1/3] Document customizable binary operators I learned indirectly through comments on a PR that \otimes and \oplus and \odot can be extended as binary operators yet I cannot find this fact anywhere in the documentation. Search the docs for `oplus` yields nothing. Somewhere there must be a list of which characters can be extended this way and it should be documented in the manual. This PR is an attempt to get that ball rolling! --- doc/src/base/math.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/src/base/math.md b/doc/src/base/math.md index 343c71f03c4b4..1eec27cf29ab7 100644 --- a/doc/src/base/math.md +++ b/doc/src/base/math.md @@ -176,3 +176,20 @@ Base.widemul Base.Math.@evalpoly Base.FastMath.@fastmath ``` + +## Customizable binary operators + +Some unicode characters can be used to define new binary operators +that support infix notation. +For example +```⊗(x,y) = kron(x,y)``` +defines the `⊗` (otimes) function to be the Kronecker product, +and one can call it as binary operator using infix syntax: +```C = A ⊗ B``` +as well as with the usual postfix syntax +```C = ⊗(A,B)```. + +Other characters that support such extensions include +\odot `⊙` +and +\oplus `⊕` From c2bddc0c6f25a12d9fb05e58dd478f75b7e5d95b Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Sun, 6 Oct 2019 12:17:33 -0400 Subject: [PATCH 2/3] Add url for list and fix prefix typo --- doc/src/base/math.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/src/base/math.md b/doc/src/base/math.md index 1eec27cf29ab7..7303fce5fc135 100644 --- a/doc/src/base/math.md +++ b/doc/src/base/math.md @@ -186,10 +186,15 @@ For example defines the `⊗` (otimes) function to be the Kronecker product, and one can call it as binary operator using infix syntax: ```C = A ⊗ B``` -as well as with the usual postfix syntax +as well as with the usual prefix syntax ```C = ⊗(A,B)```. Other characters that support such extensions include \odot `⊙` and \oplus `⊕` + +The complete list is here: +https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm#L29 +and looks like this: +`* / ÷ % & ⋅ ∘ × |\\| ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇ ⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻ ⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗` From e979bc9e412819691b6384d34d60ba6165a47431 Mon Sep 17 00:00:00 2001 From: Jeff Fessler Date: Sun, 6 Oct 2019 13:25:24 -0400 Subject: [PATCH 3/3] Expand docs of infix binary operators. --- doc/src/base/math.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/src/base/math.md b/doc/src/base/math.md index 7303fce5fc135..387b32fab8049 100644 --- a/doc/src/base/math.md +++ b/doc/src/base/math.md @@ -194,7 +194,11 @@ Other characters that support such extensions include and \oplus `⊕` -The complete list is here: -https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm#L29 -and looks like this: +The complete list is in the parser code: +https://github.com/JuliaLang/julia/blob/master/src/julia-parser.scm + +Those that are parsed like `*` (in terms of precedence) include `* / ÷ % & ⋅ ∘ × |\\| ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇ ⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻ ⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗` +and those that are parsed like `+` include +`+ - |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣` +There are many others that are related to arrows, comparisons, and powers.