System Function FMT: Difference between revisions
No edit summary |
(t/c) |
||
(17 intermediate revisions by 3 users not shown) | |||
Line 18: | Line 18: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll>Z</apll> is a | <td><apll>Z</apll> is a Character MATRIX which reveals the array structure and types of the elements of <apll>R</apll>.</td> | ||
</tr> | </tr> | ||
Line 26: | Line 26: | ||
<p>For example,</p> | <p>For example,</p> | ||
<pre | <pre> | ||
⎕fmt ⍳3 | ⎕fmt ⍳3 | ||
┌3────┐ | ┌3────┐ | ||
│1 2 3│ | │1 2 3│ | ||
└~────┘ | └~────┘ | ||
⎕fmt ⍳¨⍳3 | ⎕fmt ⍳¨⍳3 | ||
┌3──────────────────┐ | |||
│ ┌1┐ | │ ┌1┐ ┌2──┐ ┌3────┐ │ | ||
│ │1│ | │ │1│ │1 2│ │1 2 3│ │ | ||
│ └~┘ | │ └~┘ └~──┘ └~────┘ 2 | ||
└∊──────────────────┘ | |||
⎕fmt 1 1 4⍴23 'abc' '*' (2 3⍴⍳6) | ⎕fmt 1 1 4⍴23 'abc' '*' (2 3⍴⍳6) | ||
┌┬4────────────────────┐ | |||
11 | 11 ┌3──┐ ┌3─────┐ │ | ||
││ 23 | ││ 23 │abc│ * 2 1 2 3│ │ | ||
││ ~~ | ││ ~~ └───┘ ¯ │ 4 5 6│ │ | ||
││ | ││ └~─────┘ 2 | ||
└┴∊────────────────────┘ | |||
</pre> | </pre> | ||
<p>This function is implemented via the Magic Functions <apll>#MonFMT</apll> and <apll>#Box</apll>.</p> | <p>This function is implemented via the Magic Functions <apll>#MonFMT</apll> and <apll>#Box</apll>. The design is based upon ideas from Rabenhorst<sup>1</sup>.</p> | ||
<p><sup>1</sup> [http://portal.acm.org/citation.cfm?id=55664 "The Compact Display of Arbitrary Nested Arrays"] D. A. Rabenhorst (IBM), APL88 Conference Proceedings, pp 272-277, ACM.</p> | |||
<hr width=55%> | |||
APL code for Magic Function #BoxFMT(July 2015): | |||
<pre> | |||
2 ⎕CR '#BoxFMT' | |||
Z←Z #BoxFMT R;RD;LD;D | |||
LD←⍕(0≠⍴⍴R)/¯1↑⍴R | |||
RD←⍕⍪¯1↓⍴R | |||
RD←(+/RD=' ')⌽RD | |||
D←¯2+⍴⍴Z | |||
:if D>0 | |||
:while 2<⍴⍴Z | |||
Z←,[¯3 ¯2] Z,[¯2]' ' | |||
:endwhile | |||
Z←(-D)↓[0]Z | |||
:endif | |||
Z←(¯2↑1,⍴Z)⍴Z ⋄ Z←((⍴Z)⌈(¯1↑⍴RD),⍴LD)↑Z | |||
:if 1≥⍴⍴R | |||
RD←((1↑⍴Z),1)⍴'│' | |||
:else | |||
RD←⍉(1↑⍴Z)↑[1] RD ⋄ RD[(,RD=' ')/,⍳⍴RD]←'│' | |||
:endif | |||
RD←'┬'⍪RD⍪'┴' ⋄ RD[0 ¯1;0]←'┌└' | |||
Z←Z,'│' | |||
D←≡R | |||
:if 1<D | |||
D←⍕D | |||
Z[⍳-⍴D;¯1]←⌽D | |||
:endif | |||
Z←'─'⍪Z⍪'─' | |||
Z[0 ¯1;¯1]←'┐┘' | |||
Z[0;⍳⍴LD]←LD | |||
Z[¯1;0]←Type | |||
Z←RD,Z | |||
</pre> | |||
For a list of <u>all</u> magic functions implemented in NARS, see [[System_Function_NL|⎕NL 23 24]] | |||
==Dyadic Function== | ==Dyadic Function== | ||
Line 66: | Line 105: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll>R</apll> is a simple scalar, vector, or | <td><apll>R</apll> is a simple array or a nested vector of simple arrays — this is the array to be formatted.</td> | ||
</tr> | |||
<tr> | |||
<td><apll>L</apll> is a character scalar or vector — this is the format specification.</td> | |||
</tr> | |||
</table> | |||
<br><big>'''Quad FMT''' sample ''dyadic'' usage:</big> | |||
<big><pre> | |||
'CI 14' ⎕FMT ⎕WA ⍝ C=use commas(",") modifier; I=Integer format; 14=reserve 14 spaces. ⎕WA=free workspace area. | |||
50,825,084,928 ⍝ Result shown by APL, commas inserted. Easily readable, over 50 gigabytes of free work area. | |||
'CI 13' ⎕FMT ⎕WA ⍝ Same as 1st example, but too FEW spaces allowed for(only 13); hence, APL returns all asterisks(*). | |||
************* | |||
'CF 14.2' ⎕FMT 44888.769 ⍝ C=Commas modifier, F=Floating point number format; 14 reserved spaces; 2 decimals. .769 to .77 | |||
44,888.77 | |||
'G<99/99/9999>' ⎕FMT 03042015 ⍝ G<...>=General picture formatting(like Cobol Gen picture fmt), in this case formatting for a date! | |||
03/04/2015 | |||
⍴('G<99/99/9999>' ⎕FMT 03042015) ⍝ Note that OUTPUT from ⎕FMT is a Char/string MATRIX (NOT a vector), in this case a ONE ROW matrix. | |||
1 10 | |||
'G<(999) 999-9999>' ⎕FMT 8005126200 8004443300 ⍝ Formatting for telephone numbers. Output = 2-row character matrix. | |||
(800) 512-6200 | |||
(800) 444-3300 | |||
</pre></big> | |||
<br /> | |||
<p>Based upon the original STSC implementation in the early 1970s, this function performs a wide variety of formatting tasks such as Integer, Decimal, Exponential, Alphabetic, and Picture formatting.</p> | |||
<p>The left argument consists of zero or more format phrases each separated by a comma and zero or more spaces. A format phrase consists of an optional Repetition factor, zero or more Qualifiers, zero or more Decorators, a Phrase Type, and possibly width or other numeric information depending upon the Phrase Type.</p> | |||
<br /> | |||
<p>The list of Phrase Types consists of</p> | |||
<table border="1" cellpadding="5" cellspacing="0" rules = "none" summary=""> | |||
<tr> | |||
<td><apll>A</apll><i>w</i></td> | |||
<td>Character format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>E</apll><i>w.s</i></td> | |||
<td>Exponential format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>F</apll><i>w.d</i></td> | |||
<td>Decimal format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>G</apll><picture></td> | |||
<td>Picture format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>I</apll><i>w</i></td> | |||
<td>Integer format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>R</apll><i>w.d</i></td> | |||
<td>Rational format</td> | |||
</tr> | |||
<tr> | |||
<td><apll>T</apll></td> | |||
<td>Rightmost positioning</td> | |||
</tr> | |||
<tr> | |||
<td><apll>T</apll><i>p</i></td> | |||
<td>Absolute positioning</td> | |||
</tr> | |||
<tr> | |||
<td><apll>X</apll><i>w</i></td> | |||
<td>Relative positioning where <i>w</i> may be negative as in <apll>X¯3</apll> or <apll>X-3</apll></td> | |||
</tr> | |||
</table> | |||
<br /> | |||
<p>The list of Qualifiers consists of</p> | |||
<table border="1" cellpadding="5" cellspacing="0" rules = "none" summary=""> | |||
<tr> | |||
<td><apll>B</apll></td> | |||
<td>Blank if zero</td> | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><apll> | <td><apll>C</apll></td> | ||
<td>Comma (thousands separator) insertion</td> | |||
</tr> | </tr> | ||
<tr> | |||
<td><apll>K</apll><i>n</i></td> | |||
<td>Scaling by 10<sup>n</sup> where <i>n</i> may be negative as in <apll>K¯3</apll> or <apll>K-3</apll></td> | |||
</tr> | |||
<tr> | |||
<td><apll>L</apll></td> | |||
<td>Left justification</td> | |||
</tr> | |||
<tr> | |||
<td><apll>Z</apll></td> | |||
<td>Zero fill</td> | |||
</tr> | |||
</table> | |||
<br /> | |||
<p>The list of Decorators consists of a Decorator Type followed by <i>text</i>, where the <i>text</i> is surrounded by delimiters which come in pairs such as</p> | |||
<apll>'...'</apll><br /> | |||
<apll>"..."</apll><br /> | |||
<apll>⎕...⎕</apll><br /> | |||
<apll>⍞...⍞</apll><br /> | |||
<apll>¨...¨</apll><br /> | |||
<apll><...></apll><br /> | |||
<apll>⊂...⊃</apll> | |||
<p>The list of Decorators consists of</p> | |||
<table border="1" cellpadding="5" cellspacing="0" rules = "none" summary=""> | |||
<tr> | |||
<td><apll>M</apll><<i>text</i>></td> | |||
<td>Negative left decoration</td> | |||
</tr> | |||
<tr> | |||
<td><apll>N</apll><<i>text</i>></td> | |||
<td>Negative right decoration</td> | |||
</tr> | |||
<tr> | |||
<td><apll>O</apll><<i>text</i>></td> | |||
<td>Zero substitution</td> | |||
</tr> | |||
<tr> | |||
<td><apll>O</apll>n<<i>text</i>></td> | |||
<td>Specific value substitution where <i>n</i> may be negative as in <apll>O¯2<<i>text</i>></apll> or <apll>O-2<<i>text</i>></apll></td> | |||
</tr> | |||
<tr> | |||
<td><apll>P</apll><<i>text</i>></td> | |||
<td>Positive and zero left decoration</td> | |||
</tr> | |||
<tr> | |||
<td><apll>Q</apll><<i>text</i>></td> | |||
<td>Positive and zero right decoration</td> | |||
</tr> | |||
<tr> | |||
<td><apll>R</apll><<i>text</i>></td> | |||
<td>Background fill</td> | |||
</tr> | |||
<tr> | |||
<td><apll>S</apll><<i>text</i>></td> | |||
<td>Symbol substitution</td> | |||
</tr> | |||
</table> | </table> | ||
<br /> | <br /> | ||
<p> | <p>Within a Format Phrase, Qualifiers and Decorators may appear in any order, and may be separated from each other and the Phrase Type by zero or more spaces.</p> | ||
===Character Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>A</apll><i>w</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>L</apll> only is allowed), <i>d</i> is an optional decorator (<apll>R</apll> and <apll>S</apll> are allowed), and <i>w</i> is the field width in which each character is placed, right- or left-justified as per the absence/presence of the <apll>L</apll> qualifier.</p> | |||
===Exponential Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>E</apll><i>w</i>.<i>s</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>B</apll>, <apll>K</apll>, <apll>L</apll>, and <apll>Z</apll> are allowed), <i>d</i> is an optional decorator (<apll>M</apll>, <apll>N</apll>, <apll>O</apll>, <apll>P</apll>, <apll>Q</apll>, <apll>R</apll>, and <apll>S</apll> are allowed), <i>w</i> is the field width, and <i>s</i> is the number of significant digits displayed.</p> | |||
===Decimal Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>F</apll><i>w</i>.<i>d</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>B</apll>, <apll>C</apll>, <apll>K</apll>, <apll>L</apll>, and <apll>Z</apll> are allowed), <i>d</i> is an optional decorator (<apll>M</apll>, <apll>N</apll>, <apll>O</apll>, <apll>P</apll>, <apll>Q</apll>, <apll>R</apll>, and <apll>S</apll> are allowed), <i>w</i> is the field width, and <i>d</i> is the number of decimal digits displayed.</p> | |||
===Picture Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>G</apll><<i>text</i>></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>B</apll> and <apll>K</apll> are allowed), <i>d</i> is an optional decorator (<apll>M</apll>, <apll>O</apll>, <apll>P</apll>, <apll>R</apll>, and <apll>S</apll> are allowed), and <i>text</i> is the pattern for the picture format.</p> | |||
===Integer Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>I</apll><i>w</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>B</apll>, <apll>C</apll>, <apll>K</apll>, <apll>L</apll>, and <apll>Z</apll> are allowed), <i>d</i> is an optional decorator (<apll>M</apll>, <apll>N</apll>, <apll>O</apll>, <apll>P</apll>, <apll>Q</apll>, <apll>R</apll>, and <apll>S</apll> are allowed), and <i>w</i> is the field width.</p> | |||
===Rational Format Phrase=== | |||
<p><b>Form:</b> <i>rqd</i><apll>R</apll><i>w</i>.<i>d</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>q</i> is an optional qualifier (<apll>B</apll>, <apll>C</apll>, <apll>K</apll>, <apll>L</apll>, and <apll>Z</apll> are allowed), <i>d</i> is an optional decorator (<apll>M</apll>, <apll>N</apll>, <apll>O</apll>, <apll>P</apll>, <apll>Q</apll>, <apll>R</apll>, and <apll>S</apll> are allowed), <i>w</i> is the field width, and <i>d</i> is the number of digits displayed in the denominator.</p> | |||
===Absolute Positioning Phrase=== | |||
<p><b>Form:</b> <apll>T</apll> or <apll>T</apll><i>p</i></p> | |||
<p>where <i>p</i> is the absolute (origin-1) position in the line. If <i>p</i> is zero or is omitted, the next character is inserted at the rightmost position of the line.</p> | |||
===Relative Positioning Phrase=== | |||
<p><b>Form:</b> <i>r</i><apll>X</apll><i>w</i></p> | |||
<p>where <i>r</i> is an optional repetition factor, <i>w</i> is the (signed) field width, that is the number of spaces to move to the left (<i>w</i> < 0) or right (<i>w</i> > 0).</p> | |||
===Symbol Substitution=== | |||
<p>All but the Positioning Phrases allow alternate symbols to be used in place of certain standard symbols. For example, the thousands separator used by the <apll>C</apll> qualifier may be substituted with a dot using <apll>S<,.></apll>, the decimal point used in numeric format phrases may be substituted with a comma using <apll>S<.,></apll>, and both may be substituted at the same time using <apll>S<,..,></apll> or <apll>S<.,,.></apll>.</p> | |||
<p>In general, the text portion of Symbol Substitution consists of pairs of characters. The first character in each pair consists of a standard symbol which identifies the substitution class and is its default value. The second character in each pair is the (new) symbol to be used when the corresponding standard symbol is called for. Each standard symbol may appear as the first character in a pair at most once in each <apll>S</apll> Decorator. The order of the pairs is unimportant.</p> | |||
<p>The list of substitution classes along with their (standard symbols) and the Format Phrases/Qualifiers in which they are allowed is as follows:</p> | |||
<table border="1" cellpadding="5" cellspacing="0" rules = "none" summary=""> | |||
<tr> | |||
<td>Overflow (<apll>*</apll>)</td> | |||
<td>Format Phrases: <apll>A</apll>, <apll>E</apll>, <apll>F</apll>, <apll>G</apll>, and <apll>I</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Decimal Separator (<apll>.</apll>)</td> | |||
<td>Format Phrases: <apll>E</apll>, <apll>F</apll>, and <apll>I</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Thousands Separator (<apll>,</apll>)</td> | |||
<td>Qualifier: <apll>C</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Exponent Separator (<apll>E</apll>)</td> | |||
<td>Format Phrase: <apll>E</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Zero Fill (<apll>0</apll>)</td> | |||
<td>Qualifier: <apll>Z</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Precision Loss Fill (<apll>_</apll>)</td> | |||
<td>Format Phrases: <apll>E</apll>, <apll>F</apll>, and <apll>I</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Z Character (<apll>Z</apll>)</td> | |||
<td>Format Phrase: <apll>G</apll></td> | |||
</tr> | |||
<tr> | |||
<td>9 Character (<apll>9</apll>)</td> | |||
<td>Format Phrase: <apll>G</apll></td> | |||
</tr> | |||
<tr> | |||
<td>Rational Separator (<apll>r</apll>)</td> | |||
<td>Format Phrase: <apll>R</apll></td> | |||
</tr> | |||
</table> | |||
<br /> | |||
===Specific Value Substitution=== | |||
<p>The <apll>O</apll> decorator may be used to substitute arbitrary text for any given value. Originally, it was designed as a generalization of the <apll>B</apll> Qualifier to allow arbitrary text to appear in place of a zero, as in <apll>O<Zilch>I8</apll>. Later, it was generalized even farther to substitute values other than zero, as in <apll>O2<Twice>I6</apll> or <apll>O3.141592653589793<π>F10.2</apll>.</p> | |||
<p>The comparison of incoming data with the specific values is done using Comparison Tolerance.</p> | |||
<p>Unlike all other Decorators, this one may appear multiple times within a single Format Phrase.</p> | |||
{{SFDM|FMT}} | |||
{{Article footer|0|NO}} |
Latest revision as of 17:20, 13 October 2019
Monadic Function
|
||||
R is an arbitrary array. | ||||
Z is a Character MATRIX which reveals the array structure and types of the elements of R. |
For example,
⎕fmt ⍳3 ┌3────┐ │1 2 3│ └~────┘ ⎕fmt ⍳¨⍳3 ┌3──────────────────┐ │ ┌1┐ ┌2──┐ ┌3────┐ │ │ │1│ │1 2│ │1 2 3│ │ │ └~┘ └~──┘ └~────┘ 2 └∊──────────────────┘ ⎕fmt 1 1 4⍴23 'abc' '*' (2 3⍴⍳6) ┌┬4────────────────────┐ 11 ┌3──┐ ┌3─────┐ │ ││ 23 │abc│ * 2 1 2 3│ │ ││ ~~ └───┘ ¯ │ 4 5 6│ │ ││ └~─────┘ 2 └┴∊────────────────────┘
This function is implemented via the Magic Functions #MonFMT and #Box. The design is based upon ideas from Rabenhorst1.
1 "The Compact Display of Arbitrary Nested Arrays" D. A. Rabenhorst (IBM), APL88 Conference Proceedings, pp 272-277, ACM.
APL code for Magic Function #BoxFMT(July 2015):
2 ⎕CR '#BoxFMT' Z←Z #BoxFMT R;RD;LD;D LD←⍕(0≠⍴⍴R)/¯1↑⍴R RD←⍕⍪¯1↓⍴R RD←(+/RD=' ')⌽RD D←¯2+⍴⍴Z :if D>0 :while 2<⍴⍴Z Z←,[¯3 ¯2] Z,[¯2]' ' :endwhile Z←(-D)↓[0]Z :endif Z←(¯2↑1,⍴Z)⍴Z ⋄ Z←((⍴Z)⌈(¯1↑⍴RD),⍴LD)↑Z :if 1≥⍴⍴R RD←((1↑⍴Z),1)⍴'│' :else RD←⍉(1↑⍴Z)↑[1] RD ⋄ RD[(,RD=' ')/,⍳⍴RD]←'│' :endif RD←'┬'⍪RD⍪'┴' ⋄ RD[0 ¯1;0]←'┌└' Z←Z,'│' D←≡R :if 1<D D←⍕D Z[⍳-⍴D;¯1]←⌽D :endif Z←'─'⍪Z⍪'─' Z[0 ¯1;¯1]←'┐┘' Z[0;⍳⍴LD]←LD Z[¯1;0]←Type Z←RD,Z
For a list of all magic functions implemented in NARS, see ⎕NL 23 24
Dyadic Function
|
||||
R is a simple array or a nested vector of simple arrays — this is the array to be formatted. | ||||
L is a character scalar or vector — this is the format specification. |
Quad FMT sample dyadic usage:
'CI 14' ⎕FMT ⎕WA ⍝ C=use commas(",") modifier; I=Integer format; 14=reserve 14 spaces. ⎕WA=free workspace area. 50,825,084,928 ⍝ Result shown by APL, commas inserted. Easily readable, over 50 gigabytes of free work area. 'CI 13' ⎕FMT ⎕WA ⍝ Same as 1st example, but too FEW spaces allowed for(only 13); hence, APL returns all asterisks(*). ************* 'CF 14.2' ⎕FMT 44888.769 ⍝ C=Commas modifier, F=Floating point number format; 14 reserved spaces; 2 decimals. .769 to .77 44,888.77 'G<99/99/9999>' ⎕FMT 03042015 ⍝ G<...>=General picture formatting(like Cobol Gen picture fmt), in this case formatting for a date! 03/04/2015 ⍴('G<99/99/9999>' ⎕FMT 03042015) ⍝ Note that OUTPUT from ⎕FMT is a Char/string MATRIX (NOT a vector), in this case a ONE ROW matrix. 1 10 'G<(999) 999-9999>' ⎕FMT 8005126200 8004443300 ⍝ Formatting for telephone numbers. Output = 2-row character matrix. (800) 512-6200 (800) 444-3300
Based upon the original STSC implementation in the early 1970s, this function performs a wide variety of formatting tasks such as Integer, Decimal, Exponential, Alphabetic, and Picture formatting.
The left argument consists of zero or more format phrases each separated by a comma and zero or more spaces. A format phrase consists of an optional Repetition factor, zero or more Qualifiers, zero or more Decorators, a Phrase Type, and possibly width or other numeric information depending upon the Phrase Type.
The list of Phrase Types consists of
Aw | Character format |
Ew.s | Exponential format |
Fw.d | Decimal format |
G<picture> | Picture format |
Iw | Integer format |
Rw.d | Rational format |
T | Rightmost positioning |
Tp | Absolute positioning |
Xw | Relative positioning where w may be negative as in X¯3 or X-3 |
The list of Qualifiers consists of
B | Blank if zero |
C | Comma (thousands separator) insertion |
Kn | Scaling by 10n where n may be negative as in K¯3 or K-3 |
L | Left justification |
Z | Zero fill |
The list of Decorators consists of a Decorator Type followed by text, where the text is surrounded by delimiters which come in pairs such as
'...'
"..."
⎕...⎕
⍞...⍞
¨...¨
<...>
⊂...⊃
The list of Decorators consists of
M<text> | Negative left decoration |
N<text> | Negative right decoration |
O<text> | Zero substitution |
On<text> | Specific value substitution where n may be negative as in O¯2<text> or O-2<text> |
P<text> | Positive and zero left decoration |
Q<text> | Positive and zero right decoration |
R<text> | Background fill |
S<text> | Symbol substitution |
Within a Format Phrase, Qualifiers and Decorators may appear in any order, and may be separated from each other and the Phrase Type by zero or more spaces.
Character Format Phrase
Form: rqdAw
where r is an optional repetition factor, q is an optional qualifier (L only is allowed), d is an optional decorator (R and S are allowed), and w is the field width in which each character is placed, right- or left-justified as per the absence/presence of the L qualifier.
Exponential Format Phrase
Form: rqdEw.s
where r is an optional repetition factor, q is an optional qualifier (B, K, L, and Z are allowed), d is an optional decorator (M, N, O, P, Q, R, and S are allowed), w is the field width, and s is the number of significant digits displayed.
Decimal Format Phrase
Form: rqdFw.d
where r is an optional repetition factor, q is an optional qualifier (B, C, K, L, and Z are allowed), d is an optional decorator (M, N, O, P, Q, R, and S are allowed), w is the field width, and d is the number of decimal digits displayed.
Picture Format Phrase
Form: rqdG<text>
where r is an optional repetition factor, q is an optional qualifier (B and K are allowed), d is an optional decorator (M, O, P, R, and S are allowed), and text is the pattern for the picture format.
Integer Format Phrase
Form: rqdIw
where r is an optional repetition factor, q is an optional qualifier (B, C, K, L, and Z are allowed), d is an optional decorator (M, N, O, P, Q, R, and S are allowed), and w is the field width.
Rational Format Phrase
Form: rqdRw.d
where r is an optional repetition factor, q is an optional qualifier (B, C, K, L, and Z are allowed), d is an optional decorator (M, N, O, P, Q, R, and S are allowed), w is the field width, and d is the number of digits displayed in the denominator.
Absolute Positioning Phrase
Form: T or Tp
where p is the absolute (origin-1) position in the line. If p is zero or is omitted, the next character is inserted at the rightmost position of the line.
Relative Positioning Phrase
Form: rXw
where r is an optional repetition factor, w is the (signed) field width, that is the number of spaces to move to the left (w < 0) or right (w > 0).
Symbol Substitution
All but the Positioning Phrases allow alternate symbols to be used in place of certain standard symbols. For example, the thousands separator used by the C qualifier may be substituted with a dot using S<,.>, the decimal point used in numeric format phrases may be substituted with a comma using S<.,>, and both may be substituted at the same time using S<,..,> or S<.,,.>.
In general, the text portion of Symbol Substitution consists of pairs of characters. The first character in each pair consists of a standard symbol which identifies the substitution class and is its default value. The second character in each pair is the (new) symbol to be used when the corresponding standard symbol is called for. Each standard symbol may appear as the first character in a pair at most once in each S Decorator. The order of the pairs is unimportant.
The list of substitution classes along with their (standard symbols) and the Format Phrases/Qualifiers in which they are allowed is as follows:
Overflow (*) | Format Phrases: A, E, F, G, and I |
Decimal Separator (.) | Format Phrases: E, F, and I |
Thousands Separator (,) | Qualifier: C |
Exponent Separator (E) | Format Phrase: E |
Zero Fill (0) | Qualifier: Z |
Precision Loss Fill (_) | Format Phrases: E, F, and I |
Z Character (Z) | Format Phrase: G |
9 Character (9) | Format Phrase: G |
Rational Separator (r) | Format Phrase: R |
Specific Value Substitution
The O decorator may be used to substitute arbitrary text for any given value. Originally, it was designed as a generalization of the B Qualifier to allow arbitrary text to appear in place of a zero, as in O<Zilch>I8. Later, it was generalized even farther to substitute values other than zero, as in O2<Twice>I6 or O3.141592653589793<π>F10.2.
The comparison of incoming data with the specific values is done using Comparison Tolerance.
Unlike all other Decorators, this one may appear multiple times within a single Format Phrase.
Note: ⎕FMT 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 |
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 |