Conformability: Difference between revisions

Jump to navigation Jump to search
→‎Frame conformability: NARS2000 has singleton extension for frame conformability
Miraheze>Adám Brudzewsky
m (Text replacement - "{{APL programming language}}" to "{{APL features}}")
 
(→‎Frame conformability: NARS2000 has singleton extension for frame conformability)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''Conformability''' describes the conditions that must be satisfied by [[argument]]s to [[dyadic]] [[scalar function]]s. The arguments must match in [[shape]], taking into account [[scalar extension]] and, when it is supported, [[singleton extension]]. The criteria which determine the result shape are often considered part of conformability as well. Some functionality, such as [[multiple assignment]], might use modified conformability rules.
'''Conformability''' describes the conditions that must be satisfied by [[argument]]s to [[dyadic]] [[scalar function]]s. The arguments must match in [[shape]], taking into account [[scalar extension]] and, when supported, [[singleton extension]] or [[leading axis agreement]]. The criteria which determine the result shape are often considered part of conformability as well. The [[Each]] operator also checks conformability when called dyadically, and some functionality, such as [[multiple assignment]], might use modified conformability rules.


Two arguments are said to conform when either
Two arguments are said to conform when they have matching shapes, or one of them is extendible to match the other's shape. Possible rules for extensibility are:
* They have identical shapes, or
* [[Scalar extension]]: one argument is a [[scalar]] (this is used in all APLs).
* One of them is extendible (it is a scalar, or, in languages with [[singleton extension]], has exacly one element).
* [[Singleton extension]]: at least one argument is a [[singleton]].
* [[Leading axis agreement]]: one argument's shape is a [[prefix]] of the other's. This is a superset of scalar extension.


The result shape associated with such arguments can then be determined:
The result shape associated with such arguments can then be determined:
Line 10: Line 11:
* Otherwise, it is the shape of the argument with the largest rank (this condition is only possible with [[singleton extension]]).
* Otherwise, it is the shape of the argument with the largest rank (this condition is only possible with [[singleton extension]]).


== Frame conformability ==


{{APL features}}
{{main|Frame agreement}}
 
The [[Rank operator]] and [[function rank]] check for conformability not on the entire [[shape]]s of arguments, but only on their [[frame]]s. The same procedure applies to determine whether two frames conform, and if function <syntaxhighlight lang=apl inline>f</syntaxhighlight>'s result shape is known, then the result shape of <syntaxhighlight lang=apl inline>f⍤l r</syntaxhighlight> can be found by appending it to the shape obtained from conformability on the frames computed from [[Rank (operator)|ranks]] <syntaxhighlight lang=apl inline>l</syntaxhighlight> and <syntaxhighlight lang=apl inline>r</syntaxhighlight>. Rather than copying [[element]]s of the extended argument to match the other one, [[cell]]s are copied.
 
Frame conformability may not allow [[singleton extension]] even when ordinary conformability supports it: [[Dyalog APL]], [[SHARP APL]], and [[A+]] have singleton extension for scalar dyadics but not for Rank (and [[J]] doesn't implement singleton extension). Of these, [[J]] and [[A+]] use [[leading axis agreement]] while SHARP and Dyalog use only empty-frame extension, the equivalent of scalar extension. However, [[NARS2000]] implements Rank with singleton extension for frames.
 
== External links ==
 
* [https://forums.dyalog.com/viewtopic.php?f=30&t=1621 Scalar functions] and [https://forums.dyalog.com/viewtopic.php?f=30&t=1622 Tally and scalar functions] by [[Roger Hui]]
{{APL features}}[[Category:Function characteristics]][[Category:Conformability]]

Navigation menu