String interpolation (included): Difference between revisions
Content added Content deleted
(Added Quackery.) |
(→{{header|Quackery}}: simplified, improved) |
||
Line 1,739: | Line 1,739: | ||
'''Not The Task''' |
'''Not The Task''' |
||
<code>interpolate$</code> replaces every instance of a specified character in a string with a specified string |
<code>interpolate$</code> replaces every instance of a specified character in a string with a specified string. |
||
<syntaxhighlight lang="Quackery"> [ |
<syntaxhighlight lang="Quackery"> [ stack ] is int.chr |
||
[ stack ] is int.str |
|||
swap |
|||
[ 2dup find |
|||
[ int.str put |
|||
tuck over found while |
|||
int.chr put |
|||
over pluck drop |
|||
[] swap witheach |
|||
[ dup int.chr share = if |
|||
[ drop int.str share ] |
|||
join ] |
|||
int.str release |
|||
int.chr release ] is interpolate$ ( $ n $ --> $ ) |
|||
$ "Mary had a lamb." char X $ "little" interpolate$ echo$ cr |
$ "Mary had a lamb." char X $ "little" interpolate$ echo$ cr |