interpolate ( str -- quot )


Vocabulary
interpolate

Inputs
stra string


Outputs
None

Word description
String interpolation using named variables and/or stack arguments, writing to the output-stream. Format directives from the formatting vocabulary can be used as well.

Notes
Stack arguments are numbered from the top of the stack, or provided anonymously by order of arguments.

Examples
USING: interpolate ; "Bob" "Alice" "Hi ${1}, it's ${0}." interpolate
Hi Bob, it's Alice.

USING: interpolate namespaces ; "Fred" "name" [ "Hi ${name}" interpolate ] with-variable
Hi Fred

USING: interpolate ; "Mr." "Anderson" "Hello, ${} ${}" interpolate
Hello, Mr. Anderson

USING: interpolate ; 1.2345 "${:011.5f}" interpolate
00001.23450


See also
interpolate>string

Definition