Format: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Format|⍕}} is a primitive function. == Examples == Format in its monadic form, alongside ravel, allows the user to concatenate numbers with strings:...")
 
No edit summary
Line 6: Line 6:
<source lang=apl>
<source lang=apl>
       supper ← 10
       supper ← 10
       'I ate ',⍕supper,'shrimp.'
       'I ate ',(⍕supper),' shrimp.'
I ate 10 shrimp.
I ate 10 shrimp.
</source>
</source>

Revision as of 11:00, 7 February 2020

Format () is a primitive function.

Examples

Format in its monadic form, alongside ravel, allows the user to concatenate numbers with strings:

      supper ← 10
      'I ate ',(⍕supper),' shrimp.'
I ate 10 shrimp.

It is very powerful when combined with execute, which allows the user to interpret a string as APL code:

       data ← 7
       ⍎'6 × ',⍕data
42