System Function NC: Difference between revisions

From NARS2000
Jump to navigationJump to search
Created quad NC page
 
m minor wording
Line 2: Line 2:
==Monadic Function==
==Monadic Function==
{{BoxStart|<apll>Z←⎕NC R</apll>
{{BoxStart|<apll>Z←⎕NC R</apll>
|Name Classification. &nbsp; &nbsp; <apll>R</apll> should be a '''string, vector or matrix''' of workspace names to show names types for.}}
|⎕Name Classification. &nbsp; &nbsp; Argument <apll>R</apll> should be a '''string, vector or matrix''' of workspace names to show names classes for.}}
{{BoxLine|<apll>R</apll> is &nbsp; a '''character Scalar, Vector or character string Matrix''' &nbsp; &nbsp; to <u>''enumerate'' name class for</u>.}}
{{BoxLine|<apll>R</apll> is &nbsp; a '''character Scalar, Vector or character string Matrix''' &nbsp; - to <u>''enumerate'' name classes for</u>.}}
{{BoxEnd|<apll>Z</apll> (returned) is a scalar or vector of name class results - e.g. a scalar or vector of integers.}}
{{BoxEnd|<apll>Z</apll> (returned) is a scalar or vector of name class results - e.g. a scalar or vector of integers.}}
<br>
<br>
Line 28: Line 28:
0                        ⍝ Name 'ABC' NOT FOUND
0                        ⍝ Name 'ABC' NOT FOUND
       ⎕NC ⊃'⍳ ' '⍴' 'A' 'ZZ'
       ⎕NC ⊃'⍳ ' '⍴' 'A' 'ZZ'
¯1 ¯1 2 0               ⍝Names '⍳ ' and '⍴' are NOT validly constructed; Variable A IS Found(2), ZZ is validly constructed but Not Found(0).
¯1 ¯1 2 0     ⍝Names '⍳ ' and '⍴' are NOT validly constructed(¯1); Variable A IS Found(2), ZZ is validly constructed but Not Found(0).
</pre>
</pre>
<br>
<br>

Revision as of 16:43, 13 February 2015

Name Classification - ⎕NC (System Function) - available in monadic form only:

Monadic Function

Z←⎕NC R ⎕Name Classification.     Argument R should be a string, vector or matrix of workspace names to show names classes for.
R is   a character Scalar, Vector or character string Matrix   - to enumerate name classes for.
Z (returned) is a scalar or vector of name class results - e.g. a scalar or vector of integers.


System function ⎕NC takes as its right argument a character string specifying a name, vector of names, or character matrix of names. It returns a numeric result which is the classification of each name:
Z will contain:
1 = line label (if ⎕NC called from WITHIN a user function)
2 = variable (global variable name class, or if ⎕NC used IN a user function then local variable names class)
3 = function (for function name(s))
4 = operator
0 = name not in use
¯1 = invalid name

Examples, working with ⎕NC:

      )VARS        ⍝Show which global variables exists in the current NARS APL workspace
A B C              ⍝3 global variables names exist - A, B and C
      ⎕NC 3 2⍴'A B C '    ⍝Same use of ⎕NC with a MATRIX right argument
2 2 2                     ⍝ 2 = global variable
      ⎕NC 3 1⍴'ABC'       ⍝Matrix right argument, compare to first call to ⎕NC, just above - {3 2⍴} vs {3 1⍴}
2 2 2                     ⍝Same correct results(2 2 2) = global variable names class
      ⎕NC ⊃'A ' 'B' 'B'  ⍝Call with a disclosed Nested Vector - note the extra space after variable named 'A' >> 'A '
2 2 2
      ⎕NC ⊃'A' 'B' 'C'   ⍝This call FAILS(returns 0=name not in use) because APL sees ⎕NC 'ABC'; there is NO variable named 'ABC'.
0                        ⍝ Name 'ABC' NOT FOUND
      ⎕NC ⊃'⍳ ' '⍴' 'A' 'ZZ'
¯1 ¯1 2 0      ⍝Names '⍳ ' and '⍴' are NOT validly constructed(¯1); Variable A IS Found(2), ZZ is validly constructed but Not Found(0).


See also: Quad Name List ⎕NL

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