System Function CR: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
Line 72: Line 72:
</tr>
</tr>
<tr>
<tr>
   <td><apll>L</apll> is an integer scalar whose value is one of <apll>¯2</apll>, <apll>¯1</apll>, <apll>1</apll>, or <apll>2</apll>.</td>
   <td><apll>L</apll> is an integer scalar whose value is either <apll>1</apll> or <apll>2</apll>.</td>
</tr>
</tr>


Line 78: Line 78:
<br />
<br />


<p>If <apll>2=|L</apll>, then <apll>Z</apll> is a character matrix with as many rows as there are lines in the function (including the header), and as many columns as the longest line (including the header).</p>
<p>If the first character in <apll>R</apll> is <apll>#</apll>, then <apll>R</apll> is assumed to name an internal Magic Function; otherwise <apll>R</apll> is assumed to name a user-defined function/operator or a directly assigned function (e.g., <apll>f←+.×</apll>).</p>


<p>if <apll>1=|L</apll>, then <apll>Z</apll> is a vector of character vectors with as many elements in <apll>Z</apll> as there are lines in the function (including the header), and each element of <apll>Z</apll> is a character vector representation of the corresponding line (or header) in the function.</p>
<p>If <apll>L=2</apll>, then <apll>Z</apll> is a character matrix with as many rows as there are lines in the function (including the header), and as many columns as the longest line (including the header).</p>


<p>If <apll>L&gt;0</apll>, then <apll>R</apll> is assumed to name a user-defined function or operator.</p>
<p>If <apll>L=1</apll>, then <apll>Z</apll> is either a simple character vector (for directly assigned functions), or a vector of character vectors (for user-defined functions/operators) with as many elements in <apll>Z</apll> as there are lines in the function (including the header), and each element of <apll>Z</apll> is a character vector representation of the corresponding line (or header) in the function.</p>
 
<p>If <apll>L&lt;0</apll>, then <apll>R</apll> is assumed to name a magic function.</p>
 
<p>In both cases, the canonical representation of that function is returned, as per the above two rules.</p>


<p>For example,</p>
<p>For example,</p>


<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¯2 ⎕cr '#MonIota'<br />
<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f←+.×<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍴⎕←2 ⎕cr 'f'<br />
+.×<br />
1 3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍴⎕←1 ⎕cr 'f'<br />
+.×<br />
3<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 ⎕cr '#MonIota'<br />
Z←#MonIota R<br />
Z←#MonIota R<br />
Z←⊃∘.,/⍳¨R<br />
Z←⊃∘.,/⍳¨R<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 ⎕cr '#MonIota'<br />
&nbsp;Z←#MonIota R Z←⊃∘.,/⍳¨R<br />
</apll>
</apll>


<p>When this was written, the existing magic functions were named <apll>#MonIota</apll>, <apll>#DydIota</apll>, <apll>#MonDnShoe</apll>, <apll>#DydTilde</apll>, <apll>#MonRank</apll>, <apll>#DydRank</apll>, <apll>#Conform</apll>, <apll>#MonFMT</apll>, and <apll>#Box</apll>.
<p>When this was written, the existing magic functions were named <apll>#MonIota</apll>, <apll>#DydIota</apll>, <apll>#MonDnShoe</apll>, <apll>#DydTilde</apll>, <apll>#MonRank</apll>, <apll>#DydRank</apll>, <apll>#Conform</apll>, <apll>#MonFMT</apll>, <apll>#Box</apll>, and <apll>#MonVR</apll>.

Revision as of 17:57, 8 May 2009

Monadic Function

Z←⎕CR R returns the canonical representation of the user-defined function or operator named in R.
R is a character scalar or vector.
Z is a character matrix with as many rows as there are lines in the function (including the header), and as many columns as the longest line (including the header).


This monadic function behaves the same as described in the Extended APL Standard, except it also displays the canonical representation of an assigned function or operator.

For example,

      f←,∘⍋∘⍋∘,
      ⍴⎕←⎕cr 'f'
,∘⍋∘⍋∘,
1 7

If the assigned function references an unnamed value which is not a simple scalar, the representation shows a marker in that spot.

For example,

      f←'abcdefg'∘⎕cr
      ⎕cr 'f'
…∘⎕cr

      f←⎕cr
      ⎕cr 'f'
f
      f 'f'
f


Dyadic Function

Z←L ⎕CR R returns the canonical representation of the user-defined function or operator or magic function named in R.
R is a character scalar or vector.
L is an integer scalar whose value is either 1 or 2.


If the first character in R is #, then R is assumed to name an internal Magic Function; otherwise R is assumed to name a user-defined function/operator or a directly assigned function (e.g., f←+.×).

If L=2, then Z is a character matrix with as many rows as there are lines in the function (including the header), and as many columns as the longest line (including the header).

If L=1, then Z is either a simple character vector (for directly assigned functions), or a vector of character vectors (for user-defined functions/operators) with as many elements in Z as there are lines in the function (including the header), and each element of Z is a character vector representation of the corresponding line (or header) in the function.

For example,

      f←+.×
      ⍴⎕←2 ⎕cr 'f'
+.×
1 3
      ⍴⎕←1 ⎕cr 'f'
+.×
3
      2 ⎕cr '#MonIota'
Z←#MonIota R
Z←⊃∘.,/⍳¨R
      1 ⎕cr '#MonIota'
 Z←#MonIota R Z←⊃∘.,/⍳¨R

When this was written, the existing magic functions were named #MonIota, #DydIota, #MonDnShoe, #DydTilde, #MonRank, #DydRank, #Conform, #MonFMT, #Box, and #MonVR.