String interpolation (included): Difference between revisions

→‎{{header|Quackery}}: simplified, improved
(Added Quackery.)
(→‎{{header|Quackery}}: simplified, improved)
Line 1,739:
'''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"> [ tempstack put] is int.chr
[ stack ] is int.str
swap
 
[ 2dup find
[ int.str put
tuck over found while
int.chr put
over pluck drop
[] swap splitwitheach
temp[ dup int.chr share = if
swap join join [ drop int.str share ]
again ] join ]
nip nip tempint.str release ] is interpolate$ ( $ n $ --> $ )
int.chr release ] is interpolate$ ( $ n $ --> $ )
 
$ "Mary had a lamb." char X $ "little" interpolate$ echo$ cr
1,462

edits