Unicode: Difference between revisions

Jump to navigation Jump to search
1,456 bytes added ,  10:37, 11 September 2022
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "</source>" to "</syntaxhighlight>")
(7 intermediate revisions by 2 users not shown)
Line 10: Line 10:
The whole basis for the confusion in a lengthy thread on comp.lang.apl entitled ''caret vs and''<ref>[https://groups.google.com/forum/#!forum/comp.lang.apl comp.lang.apl]. [https://groups.google.com/d/msg/comp.lang.apl/LTV-HTxEZI0/DAPcTrVPnmwJ caret vs and]. 28 Oct 2013&ndash;9 Dec 2013</ref> was that in some implementations the symbol for the logical [[And]] function was U+005E only, in some implementations it was U+2227 only, and in some both characters worked. The original poster encountered some APL text from the [[APL Wiki]] that had been produced by a system that supports U+005E and copied it into a system that used U+2227 only and failed on U+005E.
The whole basis for the confusion in a lengthy thread on comp.lang.apl entitled ''caret vs and''<ref>[https://groups.google.com/forum/#!forum/comp.lang.apl comp.lang.apl]. [https://groups.google.com/d/msg/comp.lang.apl/LTV-HTxEZI0/DAPcTrVPnmwJ caret vs and]. 28 Oct 2013&ndash;9 Dec 2013</ref> was that in some implementations the symbol for the logical [[And]] function was U+005E only, in some implementations it was U+2227 only, and in some both characters worked. The original poster encountered some APL text from the [[APL Wiki]] that had been produced by a system that supports U+005E and copied it into a system that used U+2227 only and failed on U+005E.


When systems differ in the set of acceptable characters for the same function, it serves only to confuse the end user to the detriment of the community. The cautious APL programmer can avoid such problems by choosing symbols that work across dialects. Note that in the below table, there is exactly one universally accepted codepoint for each symbol (these have been indicated by a single "Universal" cell stretching across the row), except for And where APL2 doesn't recognise the otherwise universal U+2227. However, APL2 does not have And extended to Least Common Multiple, so it is equivalent to Times (<source lang=apl inline>×</source>) which can therefore be used instead for truly portable code.
When systems differ in the set of acceptable characters for the same function, it serves only to confuse the end user to the detriment of the community. The cautious APL programmer can avoid such problems by choosing symbols that work across dialects. Note that in the below table, there is exactly one universally accepted codepoint for each symbol (these have been indicated by a single "Universal" cell stretching across the row), except for And where APL2 doesn't recognise the otherwise universal U+2227. However, APL2 does not have And extended to Least Common Multiple, so it is equivalent to Times (<syntaxhighlight lang=apl inline>×</syntaxhighlight>) which can therefore be used instead for truly portable code.


==Comparison of implementations==
==Comparison of implementations==
Line 18: Line 18:
|-
|-
! rowspan=2 | Star
! rowspan=2 | Star
| <source lang=apl inline>*</source> || U+002A || Asterisk || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Exponential]] || rowspan=2 | [[Power|Power]]
| <syntaxhighlight lang=apl inline>*</syntaxhighlight> || U+002A || Asterisk || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Exponential]] || rowspan=2 | [[Power|Power]]
|-
|-
| <source lang=apl inline>⋆</source> || U+26AA ||Star operator || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
| <syntaxhighlight lang=apl inline>⋆</syntaxhighlight> || U+26AA ||Star operator || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
|-
|-
! rowspan=2 | Minus
! rowspan=2 | Minus
| <source lang=apl inline>-</source> || U+002D || Hyphen-minus || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Negate]] || rowspan=2 | [[Minus]]
| <syntaxhighlight lang=apl inline>-</syntaxhighlight> || U+002D || Hyphen-minus || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Negate]] || rowspan=2 | [[Minus]]
|-
|-
| <source lang=apl inline>−</source> || U+2212 || Minus sign || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
| <syntaxhighlight lang=apl inline>−</syntaxhighlight> || U+2212 || Minus sign || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
|-
|-
! rowspan=2 | Logical And
! rowspan=2 | Logical And
| <source lang=apl inline>^</source> || U+005E || Circumflex accent  || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}} || rowspan=2 | || rowspan=2 | [[And]]
| <syntaxhighlight lang=apl inline>^</syntaxhighlight> || U+005E || Circumflex accent  || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}} || rowspan=2 | || rowspan=2 | [[And]]
|-
|-
| <source lang=apl inline>∧</source> || U+22BD || Logical And || {{No|No<ref><source lang=apl inline>×</source> (U+00D7) is a universally supported substitute</ref>}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}}
| <syntaxhighlight lang=apl inline>∧</syntaxhighlight> || U+22BD || Logical And || {{No|No<ref><syntaxhighlight lang=apl inline>×</syntaxhighlight> (U+00D7) is a universally supported substitute</ref>}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}}
|-
|-
! rowspan=2 | Stile
! rowspan=2 | Stile
| <source lang=apl inline>|</source> || U+007C || Vertical line || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Magnitude]] || rowspan=2 | [[Residue]]
| <syntaxhighlight lang=apl inline>|</syntaxhighlight> || U+007C || Vertical line || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Magnitude]] || rowspan=2 | [[Residue]]
|-
|-
| <source lang=apl inline>∣</source> || U+2212 || Divides || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
| <syntaxhighlight lang=apl inline>∣</syntaxhighlight> || U+2223 || Divides || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{Yes}} || {{No}}
|-
|-
! rowspan=2 | Tilde
! rowspan=2 | Tilde
| <source lang=apl inline>~</source> || U+007E || Tilde || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Not]] || rowspan=2 | [[Without]]
| <syntaxhighlight lang=apl inline>~</syntaxhighlight> || U+007E || Tilde || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Not]] || rowspan=2 | [[Without]]
|-
|-
| <source lang=apl inline>∼</source> || U+223C || Tilde operator || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>∼</syntaxhighlight> || U+223C || Tilde operator || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Alpha
! rowspan=2 | Alpha
| <source lang=apl inline>α</source> || U+03B1 || Greek small letter Alpha || rowspan=2 | || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Left Argument]]
| <syntaxhighlight lang=apl inline>α</syntaxhighlight> || U+03B1 || Greek small letter Alpha || rowspan=2 | || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Left Argument]]
|-
|-
| <source lang=apl inline>⍺</source> || U+237A || APL functional symbol Alpha || colspan=5 {{Yes|Universal}}
| <syntaxhighlight lang=apl inline>⍺</syntaxhighlight> || U+237A || APL functional symbol Alpha || colspan=5 {{Yes|Universal}}
|-
! rowspan=2 | Iota
| <syntaxhighlight lang=apl inline>ι</syntaxhighlight> || U+03B9 || Greek small letter Iota || {{No}} || {{No}} || {{Yes}} || {{No}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Left Argument]]
|-
| <syntaxhighlight lang=apl inline>⍳</syntaxhighlight> || U+2373 || APL functional symbol Iota || colspan=6 {{Yes|Universal}}
|-
! rowspan=2 | Rho
| <syntaxhighlight lang=apl inline>ρ</syntaxhighlight> || U+03C1 || Greek small letter Rho || {{No}} || {{No}} || {{Yes}} || {{No}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Left Argument]]
|-
| <syntaxhighlight lang=apl inline>⍴</syntaxhighlight> || U+2374 || APL functional symbol Rho || colspan=6 {{Yes|Universal}}
|-
|-
! rowspan=2 | Omega
! rowspan=2 | Omega
| <source lang=apl inline>ω</source> || U+03C9 || Greek small letter Omega || rowspan=2 | || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Right Argument]]
| <syntaxhighlight lang=apl inline>ω</syntaxhighlight> || U+03C9 || Greek small letter Omega || rowspan=2 | || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 colspan=2 | [[dfn|Right Argument]]
|-
|-
| <source lang=apl inline>⍵</source> || U+237A || APL functional symbol Omega || colspan=5 {{Yes|Universal}}
| <syntaxhighlight lang=apl inline>⍵</syntaxhighlight> || U+237A || APL functional symbol Omega || colspan=5 {{Yes|Universal}}
|-
|-
! rowspan=3 | Epsilon
! rowspan=3 | Epsilon
| <source lang=apl inline>∈</source><ref>Found by Hanspeter Moser in [https://www.gnu.org/software/apl/Bits_and_Pieces/toronto-toolkit.apl.html The Toronto Toolkit]</ref> || U+2208 || Element of || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 | [[Enlist]]/[[Type]] || rowspan=2 | [[Membership]]
| <syntaxhighlight lang=apl inline>ϵ</syntaxhighlight> || U+03F5 || Greek lunate Epsilon symbol || {{No}} || {{No}} || {{Yes}} || {{No}} || {{No}} || {{No}} || rowspan=3 | [[Enlist]]/[[Type]] || rowspan=3 | [[Membership]]
|-
| <syntaxhighlight lang=apl inline>∈</syntaxhighlight><ref>Found by Hanspeter Moser in [https://www.gnu.org/software/apl/Bits_and_Pieces/toronto-toolkit.apl.html The Toronto Toolkit]</ref> || U+2208 || Element of || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-  
|-  
| <source lang=apl inline>∊</source> || U+220A || Small Element of || colspan=6 {{Yes|Universal}}
| <syntaxhighlight lang=apl inline>∊</syntaxhighlight> || U+220A || Small Element of || colspan=6 {{Yes|Universal}}
|-
| <source lang=apl inline>ϵ</source> || U+03F5 || GREEK LUNATE EPSILON SYMBOL ||  ||  ||  || {{Yes}} ||  ||
|-
|-
! rowspan=2 | [[Jot]]
! rowspan=2 | [[Jot]]
| <source lang=apl inline>∘</source> || U+2218 || Ring operator || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Outer product]] || rowspan=2 | [[Beside]]/[[Bind]]
| <syntaxhighlight lang=apl inline>∘</syntaxhighlight> || U+2218 || Ring operator || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Outer product]] || rowspan=2 | [[Beside]]/[[Bind]]
|-
|-
| <source lang=apl inline>◦</source> || U+25E6 || White bullet || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>◦</syntaxhighlight> || U+25E6 || White bullet || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Less than or<br>equal to
! rowspan=2 | Less than or<br>equal to
| <source lang=apl inline>≤</source> || U+2264 || Less-than or equal to || colspan=6 {{Yes|Universal}} || rowspan=2 | || rowspan=2 | [[Less than or equal to|Less than or<br>equal to]]
| <syntaxhighlight lang=apl inline>≤</syntaxhighlight> || U+2264 || Less-than or equal to || colspan=6 {{Yes|Universal}} || rowspan=2 | || rowspan=2 | [[Less than or equal to|Less than or<br>equal to]]
|-
|-
| <source lang=apl inline>⩽</source> || U+2A7D || Less than or slanted equal to  || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>⩽</syntaxhighlight> || U+2A7D || Less than or slanted equal to  || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Greater than or<br>equal to
! rowspan=2 | Greater than or<br>equal to
| <source lang=apl inline>≥</source> || U+2265 || Greater than or equal to || colspan=6 {{Yes|Universal}} || rowspan=2 | || rowspan=2 | [[Greater than or equal to|Greater than or<br>equal to]]
| <syntaxhighlight lang=apl inline>≥</syntaxhighlight> || U+2265 || Greater than or equal to || colspan=6 {{Yes|Universal}} || rowspan=2 | || rowspan=2 | [[Greater than or equal to|Greater than or<br>equal to]]
|-
|-
| <source lang=apl inline>⩾</source> || U+2A7E || Greater than or slanted equal to  || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>⩾</syntaxhighlight> || U+2A7E || Greater than or slanted equal to  || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Logical Nor
! rowspan=2 | Logical Nor
| <source lang=apl inline>⊽</source> || U+22BD || Nor || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 | || rowspan=2 | [[Nor]]
| <syntaxhighlight lang=apl inline>⊽</syntaxhighlight> || U+22BD || Nor || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 | || rowspan=2 | [[Nor]]
|-
|-
| <source lang=apl inline>⍱</source> || U+2371 || APL functional symbol down caret tilde  || colspan=6 {{Yes|Universal}}
| <syntaxhighlight lang=apl inline>⍱</syntaxhighlight> || U+2371 || APL functional symbol down caret tilde  || colspan=6 {{Yes|Universal}}
|-
|-
! rowspan=2 | Logical Nand
! rowspan=2 | Logical Nand
| <source lang=apl inline>⊼</source> || U+22BC || Nand || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 | || rowspan=2 | [[Nand]]
| <syntaxhighlight lang=apl inline>⊼</syntaxhighlight> || U+22BC || Nand || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}} || rowspan=2 | || rowspan=2 | [[Nand]]
|-
|-
| <source lang=apl inline>⍱</source> || U+2372 || APL functional symbol up caret tilde  || colspan=6 {{Yes|Universal}}
| <syntaxhighlight lang=apl inline>⍱</syntaxhighlight> || U+2372 || APL functional symbol up caret tilde  || colspan=6 {{Yes|Universal}}
|-
|-
! rowspan=4 | Diamond
! rowspan=4 | Diamond
| <source lang=apl inline>⋄</source> || U+22C4 || Diamond operator || colspan=6 {{Yes|Universal}} || rowspan=4 colspan=2 | [[Statement Separator]]
| <syntaxhighlight lang=apl inline>⋄</syntaxhighlight> || U+22C4 || Diamond operator || colspan=6 {{Yes|Universal}} || rowspan=4 colspan=2 | [[Statement Separator]]
|-
|-
| <source lang=apl inline>◇</source> || U+25C7 || White Diamond    || {{No}} || {{No}} || {{No}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>◇</syntaxhighlight> || U+25C7 || White Diamond    || {{No}} || {{No}} || {{No}} || {{Yes}} || {{No}} || {{No}}
|-
|-
| <source lang=apl inline>◊</source> || U+25CA || Lozenge          || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>◊</syntaxhighlight> || U+25CA || Lozenge          || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
| <source lang=apl inline>⬦</source> || U+2B26 || Diamond          || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>⬦</syntaxhighlight> || U+2B26 || Diamond          || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Quad
! rowspan=2 | Quad
| <source lang=apl inline>⎕</source> || U+2395 || APL functional symbol Quad  || colspan=6 {{Yes|Universal}} || rowspan=2 colspan=2 | [[Quad name]]
| <syntaxhighlight lang=apl inline>⎕</syntaxhighlight> || U+2395 || APL functional symbol Quad  || colspan=6 {{Yes|Universal}} || rowspan=2 colspan=2 | [[Quad name]]
|-
|-
| <source lang=apl inline>▯</source> || U+26AA || White vertical rectangle || {{Yes}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>▯</syntaxhighlight> || U+26AA || White vertical rectangle || {{Yes}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|-
|-
! rowspan=2 | Circle
! rowspan=2 | Circle
| <source lang=apl inline>○</source> || U+25CB || White circle || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Pi Times]] || rowspan=2 | [[Circle function|Circular]]
| <syntaxhighlight lang=apl inline>○</syntaxhighlight> || U+25CB || White circle || colspan=6 {{Yes|Universal}} || rowspan=2 | [[Pi Times]] || rowspan=2 | [[Circle function|Circular]]
|-
|-
| <source lang=apl inline>⚪</source> || U+26AA || Medium white circle || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
| <syntaxhighlight lang=apl inline>⚪</syntaxhighlight> || U+26AA || Medium white circle || {{No}} || {{No}} || {{Yes}} || {{Yes}} || {{No}} || {{No}}
|}
|}


== Functionality ==
== Functionality ==
The following statements can be used to test the functionality of the symbols:
The following statements can be used to test the functionality of the symbols:
<source lang=apl>
<syntaxhighlight lang=apl>
⍎⎕← '1',(⎕UCS 16⊥0  0  2 10),'1'  ⍝ Star
⍎⎕← '1',(⎕UCS 16⊥0  0  2 10),'1'  ⍝ Star
⍎⎕← '1',(⎕UCS 16⊥2  2 12  6),'1'  ⍝ Star
⍎⎕← '1',(⎕UCS 16⊥2  2 12  6),'1'  ⍝ Star
Line 141: Line 151:
⍎⎕← '1',(⎕UCS 16⊥2  6 10 10),'1'  ⍝ Circle
⍎⎕← '1',(⎕UCS 16⊥2  6 10 10),'1'  ⍝ Circle
⍎⎕← '1',(⎕UCS 16⊥2  3  7  2),'1'  ⍝ Nand
⍎⎕← '1',(⎕UCS 16⊥2  3  7  2),'1'  ⍝ Nand
</source>
</syntaxhighlight>
Note that the last four lines will not work on a system that doesn’t support [[dfn]]s.
Note that the last four lines will not work on a system that doesn’t support [[dfn]]s.


==Atomic Vector==
==Atomic Vector==
If the [[Atomic vector]] (<source lang=apl inline>⎕AV</source>) has no room in which to include these new characters, an implementation can translate them on entry to the corresponding symbol that is in <source lang=apl inline>⎕AV</source>. [[NARS2000]] even has a means of translating symbols on the way out via Copy (<kbd>Ctrl</kbd>+<kbd>C</kbd> in Windows) to various other APL systems that don't support the same set of principal characters NARS2000 uses for the functions in the above table.
If the [[Atomic vector]] (<syntaxhighlight lang=apl inline>⎕AV</syntaxhighlight>) has no room in which to include these new characters, an implementation can translate them on entry to the corresponding symbol that is in <syntaxhighlight lang=apl inline>⎕AV</syntaxhighlight>. [[NARS2000]] even has a means of translating symbols on the way out via Copy (<kbd>Ctrl</kbd>+<kbd>C</kbd> in Windows) to various other APL systems that don't support the same set of principal characters NARS2000 uses for the functions in the above table.


==Considerations==
==Considerations==

Navigation menu