Prototype: Difference between revisions
Jump to navigation
Jump to search
→Support
Miraheze>Adám Brudzewsky No edit summary |
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' | ∊⊃ (1 2 'ab') 3 4 | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ | ||
Line 11: | Line 11: | ||
{{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>0}} | {{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>0}} | ||
<source lang=apl> | <source lang=apl> | ||
⊤↑ 1 2 'ab' | ⊤↑ (1 2 'ab') 3 4 | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ | ||
Line 17: | Line 17: | ||
</source> | </source> | ||
{{Works in|[[NARS2000]]}} | {{Works in|[[NARS2000]]}} | ||
However, an array's prototype can always be determined by | 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> | ||
⊃ 0 ⍴ | ⊃ 0 ⍴ (1 2 'ab') 3 4 | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ | ||
Line 26: | Line 26: | ||
{{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>1}} | {{Works in|[[Dyalog APL]] with [[migration level]]<nowiki>=</nowiki>1}} | ||
<source lang=apl> | <source lang=apl> | ||
⊃ 0 ⍴ | ⊃ 0 ⍴ (1 2 'ab') 3 4 | ||
┌─┬─┬──┐ | ┌─┬─┬──┐ | ||
│0│0│ │ | │0│0│ │ |