4,577
edits
m (Text replacement - "</source>" to "</syntaxhighlight>") |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
Line 5: | Line 5: | ||
== Support== | == Support== | ||
Few dialects have Type as a [[primitive function]]. [[APL2]] IUP had it,<ref>Graham, Alan. [https://dl.acm.org/doi/pdf/10.1145/22008.22033#page=4 Idioms and Problem Solving Techniques in APL2; Appendix - APL2 Idiom List: 9. Type]. [[APL86]].</ref> and thus [[Dyalog APL]] originally supported it too. However, by the time [[IBM]] released APL2, < | Few dialects have Type as a [[primitive function]]. [[APL2]] IUP had it,<ref>Graham, Alan. [https://dl.acm.org/doi/pdf/10.1145/22008.22033#page=4 Idioms and Problem Solving Techniques in APL2; Appendix - APL2 Idiom List: 9. Type]. [[APL86]].</ref> and thus [[Dyalog APL]] originally supported it too. However, by the time [[IBM]] released APL2, <syntaxhighlight lang=apl inline>∊</syntaxhighlight> (as in ''prototypical '''e'''lement'') was repurposed for [[Enlist]]. Thus, Dyalog left the Type meaning in place only when [[migration level]] is 0, while setting it to 1 or higher follows IBM's replacement meaning. [[NARS2000]] uses [[monadic]] <syntaxhighlight lang=apl inline>⊤</syntaxhighlight> (resembling the Latin letter '''T''' for '''''T'''ype''), which it inherited from [[NARS]]. [[Extended Dyalog APL]] uses monadic <syntaxhighlight lang=apl inline>⍷</syntaxhighlight> with the underscore indicating functionality of the corresponding non-underscored glyph from a non-default migration level.<ref>[[Partition]] is <syntaxhighlight lang=apl inline>⊆</syntaxhighlight> with migration level≤2 while the original glyph is <syntaxhighlight lang=apl inline>⊂</syntaxhighlight> as with migration level 3. Dyalog Language Reference Guide: [https://help.dyalog.com/latest/#Language/Symbols/Left%20Shoe.htm Left Shoe].</ref> | ||
However, in all dialects that support nested arrays, the type can be determined by enclosing/boxing the array in an empty array, and then coercing out a fill value. Since the [[array prototype]] is used as fill element, the resulting array will be the type of the original array: | However, in all dialects that support nested arrays, the type can be determined by enclosing/boxing the array in an empty array, and then coercing out a fill value. Since the [[array prototype]] is used as fill element, the resulting array will be the type of the original array: | ||
< | <syntaxhighlight lang=apl> | ||
↑ 0 ⍴ ⊂ 1 2 'ab' | ↑ 0 ⍴ ⊂ 1 2 'ab' | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Works in|[[Dyalog APL]] with [[migration level]]≥2, [[APL2]], [[APLX]]}} | {{Works in|[[Dyalog APL]] with [[migration level]]≥2, [[APL2]], [[APLX]]}} | ||
< | <syntaxhighlight lang=apl> | ||
⊃ 0 ⍴ ⊂ 1 2 'ab' | ⊃ 0 ⍴ ⊂ 1 2 'ab' | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ |