Format: Difference between revisions

Jump to navigation Jump to search
36 bytes added ,  20:55, 10 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - "http://help.dyalog.com" to "https://help.dyalog.com")
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
=== Monadic form ===
=== Monadic form ===


Format in its [[monadic]] form allows the user to convert [[Array model|arrays]] of any [[type]] into simple character arrays (for example for concatenation with other character arrays). The result usually matches the interpreter's default display, either by <source lang=apl inline>⎕←</source> or by REPL.
Format in its [[monadic]] form allows the user to convert [[Array model|arrays]] of any [[type]] into simple character arrays (for example for concatenation with other character arrays). The result usually matches the interpreter's default display, either by <syntaxhighlight lang=apl inline>⎕←</source> or by REPL.


<source lang=apl>
<syntaxhighlight lang=apl>
       supper ← 10
       supper ← 10
       'I ate ',(⍕supper),' shrimp.'
       'I ate ',(⍕supper),' shrimp.'
Line 28: Line 28:
[[Dyalog APL]] and [[NARS2000]] support column width and the number of decimal places for formatting [[numeric]] arrays. The following example formats the 2-by-3 array with 12 spaces per column, rounded to 2 decimal places:
[[Dyalog APL]] and [[NARS2000]] support column width and the number of decimal places for formatting [[numeric]] arrays. The following example formats the 2-by-3 array with 12 spaces per column, rounded to 2 decimal places:


<source lang=apl>
<syntaxhighlight lang=apl>
       ⎕←C←2 3⍴ 32.10958 0 ¯101.4914 ¯99.40878 ¯101.872 1001.48173
       ⎕←C←2 3⍴ 32.10958 0 ¯101.4914 ¯99.40878 ¯101.872 1001.48173
  32.10958    0    ¯101.4914  
  32.10958    0    ¯101.4914  
Line 44: Line 44:
[[APLX]] supports '''Format by example''', which uses string left argument for a rich set of format specifications:
[[APLX]] supports '''Format by example''', which uses string left argument for a rich set of format specifications:


<source lang=apl>
<syntaxhighlight lang=apl>
       '55.55' ⍕22.234 1.398 11.00
       '55.55' ⍕22.234 1.398 11.00
22.23 1.4 11
22.23 1.4 11

Navigation menu