System Function CR: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 2: Line 2:
==Monadic Function==
==Monadic Function==
{{BoxStart|<apll>Z←⎕CR R</apll>
{{BoxStart|<apll>Z←⎕CR R</apll>
|returns the canonical representation of the user-defined function or operator named in <apll>R</apll>.}}
|returns the canonical representation of the function/operator/hyperator named in <apll>R</apll>.}}
{{BoxLine|<apll>R</apll> is a character scalar or vector.}}
{{BoxLine|<apll>R</apll> is a character scalar or vector.}}
{{BoxEnd|<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).}}
{{BoxEnd|<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).}}
Line 10: Line 10:
<p>For example,</p>
<p>For example,</p>


<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f←,∘⍋∘⍋∘,<br />
<apll><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍴⎕←⎕cr 'f'<br />
      f←,∘⍋∘⍋∘,  
,∘⍋∘⍋∘,<br />
      ⍴⎕←⎕CR 'f'  
1 7</apll>
,∘⍋∘⍋∘,  
1 7
      f←{⍺+⍵}
      ⍴⎕←⎕CR 'f'
f←{⍺+⍵}
1 7</pre></apll>


<p>If the assigned function references an unnamed value which is not a simple scalar, the representation shows a marker in that spot.</p>
<p>If the assigned function references an unnamed value which is not a simple scalar or vector, the representation shows a marker in that spot.</p>


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


<apll>
<apll><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f←'abcdefg'∘⎕cr<br />
      f←(2 3⍴'abcdef')∘⎕CR
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⎕cr 'f'<br />
      ⎕CR 'f'  
…∘⎕cr
…∘⎕cr
</apll>
 
<br />
      f←⎕CR
<apll>
      ⎕CR 'f'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f←⎕cr<br />
f  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⎕cr 'f'<br />
      f 'f'  
f<br />
f  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f 'f'<br />
</pre></apll>
f<br />
 
</apll>
<br />
<br />


==Dyadic Function==
==Dyadic Function==
{{BoxStart|<apll>Z←L ⎕CR R</apll>
{{BoxStart|<apll>Z←L ⎕CR R</apll>
|returns the canonical representation of the user-defined function or operator or magic function named in <apll>R</apll>.}}
|returns the canonical representation of the user-defined function/operator/hyperator or magic function named in <apll>R</apll>.}}
{{BoxLine|<apll>R</apll> is a character scalar or vector.}}
{{BoxLine|<apll>R</apll> is a character scalar or vector.}}
{{BoxEnd|<apll>L</apll> is an integer scalar whose value is either <apll>1</apll> or <apll>2</apll>.}}
{{BoxEnd|<apll>L</apll> is an integer scalar whose value is either <apll>1</apll> or <apll>2</apll>.}}
<br/>
<br/>
<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 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/hyperator or a directly assigned function (e.g., <apll>f←+.×</apll>).</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=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>
Line 49: Line 51:
<p>For example,</p>
<p>For example,</p>


<apll>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f←+.×<br />
<apll><pre>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍴⎕←2 ⎕cr 'f'<br />
      f←+.×  
+.×<br />
      ⍴⎕←2 ⎕CR 'f'  
1 3<br />
+.×  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;⍴⎕←1 ⎕cr 'f'<br />
1 3  
+.×<br />
      ⍴⎕←1 ⎕CR 'f'  
3<br />
+.×  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 ⎕cr '#MonIota'<br />
3  
Z←#MonIota R<br />
      2 ⎕CR '#MonIota'  
Z←⊃∘.,/⍳¨R<br />
Z←#MonIota R  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 ⎕cr '#MonIota'<br />
Z←⊃∘.,/⍳¨R  
&nbsp;Z←#MonIota R Z←⊃∘.,/⍳¨R<br />
      1 ⎕CR '#MonIota'  
</apll>
&nbsp;Z←#MonIota R Z←⊃∘.,/⍳¨R  
</pre></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>.<br/>
<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>.<br/>


<br/>
{{SFDM|CR}}
{quad}CR is a system function, available in [[monadic]] and [[dyadic]] forms, which means you cannot assign a value to it.
{{System Variables}}

Latest revision as of 10:00, 19 March 2019

This function is available in both monadic and dyadic forms

Monadic Function

Z←⎕CR R returns the canonical representation of the function/operator/hyperator 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
      f←{⍺+⍵}
      ⍴⎕←⎕CR 'f'
f←{⍺+⍵}
1 7

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

For example,

      f←(2 3⍴'abcdef')∘⎕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/operator/hyperator 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/hyperator 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.

Note: ⎕CR is available as both a monadic and dyadic form system function, you cannot assign a value to it.

System Variables (A value may be assigned to these except for ⎕DM)
ALX CT DM DT ELX FC FEATURE FPC IC IO
LR LX PP PR PW RL SA WSID
Niladic System Functions (a value cannot be assigned to these)
A AV EM ET LC NNAMES NNUMS SI SYSID SYSVER
T TC TCBEL TCBS TCESC TCFF TCHT TCLF TCNL TCNUL
TS WA
Monadic or dyadic system functions (a value cannot be assigned to these)
AT CR DC DFT DL DR EA EC ERROR ES
EX FMT FX MF NAPPEND NC NCREATE NERASE NINFO NL
NLOCK NREAD NRENAME NREPLACE NRESIZE NSIZE NTIE NUNTIE STOP TF
TRACE UCS VR
Note that quad functions and variables (except for the ⎕A family of functions) are case insensitive


See Also
System Commands System Variables and Functions Operators


Keyboard
Alt+Shift
Alt ¨ ¯ < > × ÷
Shift ~ ! @ # $ % ^ & * ( ) _ +
Key ` 1 2 3 4 5 6 7 8 9 0 - =
Alt+Shift
Alt ? § π
Shift Q W E R T Y U I O P { } |
Key q w e r t y u i o p [ ] \
Alt+Shift
Alt
Shift A S D F G H J K L : "
Key a s d f g h j k l ; '
Alt+Shift χ
Alt
Shift Z X C V B N M < > ?
Key z x c v b n m , . /
NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x