Symbol Format: Difference between revisions

From NARS2000
Jump to navigationJump to search
(new)
 
(examples, elaborated on fmt ⍕)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
<h1> {format} &mdash; (Replace this with Meaning of symbol) &mdash; Keystroke ?ALT+X &mdash; Character 0000</h1>
<h1> {format} &mdash; (Format numbers and dates Function/Symbol) &mdash; Keystroke ALT+' &mdash; Character 9046</h1>
==Usage==
==Usage==
==Example==
==Examples==
<u>Monadic</u> Examples - Convert Numbers to Strings/Character vectors:
<pre>
      A←⎕TS  ⍝assign the current Time Stamp to variable A
      A      ⍝display A's value
2015 2 25 16 21 52 128    ⍝ Yr Mo Day Hr(24 hr clock) Min Sec Millisecs
      ⍴A      ⍝date-time stamp vector has 7 elements
7
      ⍕A      ⍝monadic format A (converts A from 7 element numeric vector into a 22 character string
2015 2 25 16 21 52 128
      ⍴⍕A
22
 
      B←32.10958 0 ¯101.4914    ⍝variable B is assigned 3 numbers
      ⍴B
3
      B
32.10958 0 ¯101.4914
      ⍕B                        ⍝format B converts the 3 numbers into a 20-character string
32.10958 0 ¯101.4914
      ⍴⍕B
20
</pre>
 
<u>Dyadic</u> Example - Convert Numbers to Strings(with column width/reserved # spaces AND rounding to # decimal places):
<pre>
      C←2 3⍴ 32.10958 0 ¯101.4914 ¯99.40878 ¯101.872 1001.48173      ⍝variable C is assigned 2x3 matrix of 6 numbers
      C                        ⍝show the contents of C (2 rows by 3 cols of positive and negative numbers)
32.10958    0    ¯101.4914
¯99.40878 ¯101.872 1001.48173
      ⍴C
2 3
 
      12 2⍕C    ⍝Dyadic format converts the 6 numbers in C - into a 2 rows by 36 cols character matrix  (12=col width, 2=round to 2 decimal places)
      32.11        0.00    ¯101.49
      ¯99.41    ¯101.87    1001.48
      ⍴(12 2⍕C)
2 36
</pre>
 
==See Also==
==See Also==
 
<h1>For more powerful number formatting, see [[System_Function_FMT|⎕FMT or Quad FMT]]'''</h1>(particularly '''⎕FMT''' ''dyadic'' calls)




{{Language Toolbar}}
{{Language Toolbar}}
[[Category:Mouse Group 10|F]]
[[Category:Symbols|F]]

Latest revision as of 16:48, 25 February 2015

⍕ — (Format numbers and dates Function/Symbol) — Keystroke ALT+' — Character 9046

Usage

Examples

Monadic Examples - Convert Numbers to Strings/Character vectors:

      A←⎕TS   ⍝assign the current Time Stamp to variable A
      A       ⍝display A's value
2015 2 25 16 21 52 128     ⍝ Yr Mo Day Hr(24 hr clock) Min Sec Millisecs
      ⍴A      ⍝date-time stamp vector has 7 elements
7
      ⍕A      ⍝monadic format A (converts A from 7 element numeric vector into a 22 character string
2015 2 25 16 21 52 128
      ⍴⍕A
22

      B←32.10958 0 ¯101.4914     ⍝variable B is assigned 3 numbers
      ⍴B
3
      B
32.10958 0 ¯101.4914
      ⍕B                        ⍝format B converts the 3 numbers into a 20-character string
32.10958 0 ¯101.4914
      ⍴⍕B
20

Dyadic Example - Convert Numbers to Strings(with column width/reserved # spaces AND rounding to # decimal places):

      C←2 3⍴ 32.10958 0 ¯101.4914 ¯99.40878 ¯101.872 1001.48173       ⍝variable C is assigned 2x3 matrix of 6 numbers
      C                        ⍝show the contents of C (2 rows by 3 cols of positive and negative numbers)
 32.10958    0     ¯101.4914 
¯99.40878 ¯101.872 1001.48173
      ⍴C
2 3

      12 2⍕C    ⍝Dyadic format converts the 6 numbers in C - into a 2 rows by 36 cols character matrix  (12=col width, 2=round to 2 decimal places)
       32.11        0.00     ¯101.49
      ¯99.41     ¯101.87     1001.48
      ⍴(12 2⍕C)
2 36

See Also

For more powerful number formatting, see ⎕FMT or Quad FMT

(particularly ⎕FMT dyadic calls)


NARS 2000 Lang
Tool
Bar
+ - × ÷ * ! ? |
< = >
~ § π .. ,
/ \ ¨ .
_ ¯
Second Row i j k i j k l g p r v x