System Function NC

From NARS2000
Revision as of 16:39, 13 February 2015 by Robert Wallick (talk | contribs) (Created quad NC page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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

Monadic Function

Z←⎕NC R Name Classification.     R should be a string, vector or matrix of workspace names to show names types for.
R is   a character Scalar, Vector or character string Matrix     to enumerate name class 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; 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