System Labels: Difference between revisions
No edit summary |
No edit summary |
||
Line 9: | Line 9: | ||
<td></td> | <td></td> | ||
<td></td> | <td></td> | ||
<td>is called where a prototype element is needed as in <apll>foo¨R</apll> where <apll>R</apll> is empty.</td> | <td>is called where a prototype element is needed as in <apll>foo¨R</apll> where <apll>R</apll> is empty, or <apll>L foo¨R</apll> where one of both of <apll>L</apll> or <apll>R</apll> is empty and the other is conformable.</td> | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
Line 45: | Line 45: | ||
* <p>In the Identity element case, the function is called with the reduction function's right argument prototype as the right argument to the user-defined function/operator; the left argument is undefined. For example, in <apll>foo/3 0⍴⊂⍳4</apll>, the (right) argument passed to the function is <apll>0 0 0 0</apll>. The return value from the function is used as the common item in the result. Thus, the <apll>⎕IDENTITY</apll> entry point is called only once even though the result may have multiple copies of the return value.</p> | * <p>In the Identity element case, the function is called with the reduction function's right argument prototype as the right argument to the user-defined function/operator; the left argument is undefined. For example, in <apll>foo/3 0⍴⊂⍳4</apll>, the (right) argument passed to the function is <apll>0 0 0 0</apll>. The return value from the function is used as the common item in the result. Thus, the <apll>⎕IDENTITY</apll> entry point is called only once even though the result may have multiple copies of the return value.</p> | ||
* <p>In the Prototype case, the user-defined function/operator is called with arguments that are the prototypes of the respective arguments.</p> | * <p>In the Prototype case, the user-defined function/operator is called with arguments that are the prototypes of the respective arguments; in the monadic case, the left argument is undefined.</p> |
Revision as of 19:48, 17 May 2010
Normally, execution of a user-defined function/operator starts execution at line one. However, in certain contexts, execution may start at a different line depending upon the context and the presence of a System Label. These special labels start with a quad symbol so as to present no confusion with normal labels. The following table lists the system labels defined so far and the special context in which they are used.
|
For example,
∇ Z←L foo R
[1] Z←L,R ⋄ →0
[2] ⎕PROTOTYPE:Z←'Prototype' ⋄ →0
[3] ⎕IDENTITY:Z←'Identity'
∇
⎕fmt foo/⍳0
┌──────────┐
│┌8───────┐│
││Identity││
│└────────┘2
└∊─────────┘
⎕fmt 1 foo¨⍬
┌0──────────┐
│┌9────────┐│
││Prototype││
│└─────────┘2
└∊──────────┘
In the Identity element case, the function is called with the reduction function's right argument prototype as the right argument to the user-defined function/operator; the left argument is undefined. For example, in foo/3 0⍴⊂⍳4, the (right) argument passed to the function is 0 0 0 0. The return value from the function is used as the common item in the result. Thus, the ⎕IDENTITY entry point is called only once even though the result may have multiple copies of the return value.
In the Prototype case, the user-defined function/operator is called with arguments that are the prototypes of the respective arguments; in the monadic case, the left argument is undefined.