String interpolation (included): Difference between revisions

Content deleted Content added
Miks1965 (talk | contribs)
PascalABC.NET
Aartaka (talk | contribs)
Add ed example
 
(2 intermediate revisions by 2 users not shown)
Line 1,052:
STD.Str.FindReplace('Mary had a X Lamb', 'X','little');
</syntaxhighlight>
 
=={{header|ed}}==
 
<syntaxhighlight lang="sed">
# by Artyom Bologov
H
,p
# Add a vertical bar to separate the template and value
2s/^/|/
,j
# Replace and print
s/X\(.*\)|\(.*\)/\2\1/p
Q
</syntaxhighlight>
 
{{out}}
 
<pre>$ ed -s interpolation.input < interpolation.ed
Newline appended
Mary has a X lamb
big
Mary has a big lamb</pre>
 
=={{header|Elena}}==
Line 1,452 ⟶ 1,474:
All interpolations in langur use double curly braces.
 
<syntaxhighlight lang="langur">val .x = "little"
writeln "Mary had a {{.x}} lamb."</syntaxhighlight>
 
Modifiers follow the interpolated value with a colon.
<syntaxhighlight lang="langur">writeln "Lamb count: {{.x : 7}}"</syntaxhighlight>
 
Modifiers may be chained within a single interpolation.
<syntaxhighlight lang="langur">writeln "Partial lamb count: {{.x : r2 : 10}}"
# rounds to 2 decimal places, then aligns to 10 code points
# (hopefully no partial lambs)
Line 2,247 ⟶ 2,269:
Mary had a X lamb.
Mary had a little lamb.
</pre>
 
=={{header|Uiua}}==
{{works with|Uiua|0.11.1}}
[https://www.uiua.org/tutorial/functions#format-strings Format strings documentation]
<syntaxhighlight lang="uiua">
$"Mary had a _ lamb." "little"
</syntaxhighlight>
{{out}}
<pre>
"Mary had a little lamb."
</pre>