String interpolation (included): Difference between revisions

Added Quackery.
No edit summary
(Added Quackery.)
Line 693:
x$ = "little"
print "Mary also had a "; ljust(x$, length(x$)); " lamb"</syntaxhighlight>
 
=={{header|Quackery}}==
 
'''The Task'''
 
Quackery does not have built-in string interpolation.
 
'''Not The Task'''
 
<code>interpolate$</code> replaces every instance of a specified character in a string with a specified string. Note that the specified string should not include the specified character as this will cause <code>interpolate$</code> to loop indefinitely.
 
<syntaxhighlight lang="Quackery"> [ temp put
swap
[ 2dup find
tuck over found while
over pluck drop
swap split
temp share
swap join join
again ]
nip nip temp release ] is interpolate$ ( $ n $ --> $ )
 
$ "Mary had a lamb." char X $ "little" interpolate$ echo$ cr
$ "Mary had a X lamb." char X $ "little" interpolate$ echo$ cr
$ "Mary had a X X lamb." char X $ "little" interpolate$ echo$ cr</syntaxhighlight>
 
{{out}}
 
<pre>Mary had a lamb.
Mary had a little lamb.
Mary had a little little lamb.
</pre>
 
==={{header|QBasic}}===
1,462

edits