Prototype: Difference between revisions
Jump to navigation
Jump to search
→Support
Miraheze>Adám Brudzewsky |
Miraheze>Adám Brudzewsky |
||
Line 4: | Line 4: | ||
A few dialects have [[Type]] as a [[primitive function]], and in those, the prototype is simply the type of the first element: | A few dialects have [[Type]] as a [[primitive function]], and in those, the prototype is simply the type of the first element: | ||
<source lang=apl> | <source lang=apl> | ||
⊤↑ (1 2 'ab') 3 4 | |||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ | ||
└─┴─┴──┘ | └─┴─┴──┘ | ||
</source> | </source> | ||
{{Works in|[[ | {{Works in|[[NARS2000]]}} | ||
<source lang=apl> | <source lang=apl> | ||
∊⊃ (1 2 'ab') 3 4 | |||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ | ||
└─┴─┴──┘ | └─┴─┴──┘ | ||
</source> | </source> | ||
{{Works in|[[ | {{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>0}} | ||
However, an array's prototype can always be determined by reshaping the array to become empty, and then coercing out a fill element: | However, an array's prototype can always be determined by reshaping the array to become empty, and then coercing out a fill element: | ||
<source lang=apl> | <source lang=apl> | ||
Line 24: | Line 24: | ||
└─┴─┴──┘ | └─┴─┴──┘ | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]] with [[migration level]]<nowiki> | {{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>≥</nowiki>2, [[APL2]], [[APLX]]}} | ||
[https://tryapl.org/?a=%u2283%200%20%u2374%20%281%202%20%27ab%27%29%203%204&run Try it now!] | |||
<source lang=apl> | <source lang=apl> | ||
⊃ 0 ⍴ (1 2 'ab') 3 4 | ⊃ 0 ⍴ (1 2 'ab') 3 4 | ||
Line 31: | Line 32: | ||
└─┴─┴──┘ | └─┴─┴──┘ | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]] with [[migration level]]<nowiki> | {{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>1}} | ||
APLs with a [[flat array model]] do not typically store prototype information, instead using only the array's type ([[character]], [[numeric]], or [[Box|boxed]]) to determine its [[Fill element|fills]]. | APLs with a [[flat array model]] do not typically store prototype information, instead using only the array's type ([[character]], [[numeric]], or [[Box|boxed]]) to determine its [[Fill element|fills]]. |