Skip to content

format

Input Stack:
args: List
pattern: String
Output Stack:
str: String
 

Format a string using printf-style formatting patterns. This allows for dynamic string construction by substituting values from a list into placeholders in a format string.

Parameters

  • pattern: A string containing format specifiers (e.g., %s, %d, %f)
  • args: A list of values to substitute into the format placeholders

Format Specifiers

Common format specifiers supported: * %s - String representation of any object * %d - Decimal integer * %f - Floating point number * %x - Hexadecimal representation * %% - Literal percent sign

For complete formatting options, see the Java Formatter documentation.

Examples

Basic string substitution:

foo%s,(,bar,),:format
PosInputOutput
0 List(bar) foobar
1 foo%s

This substitutes the string "bar" from the list into the %s placeholder in "foo%s", resulting in "foobar".

  • :list - Create lists of arguments for formatting
  • :legend - Custom legend formatting (often uses formatted strings)
  • :get - Retrieve values that can be used in format arguments
  • :map - Apply formatting to multiple items