Anonymous user
Selectively replace multiple instances of a character within a string: Difference between revisions
Selectively replace multiple instances of a character within a string (view source)
Revision as of 20:31, 10 June 2022
, 2 years ago→{{header|Lambdatalk}}: shorter
m (→{{header|Lambdatalk}}: small bug) |
m (→{{header|Lambdatalk}}: shorter) |
||
Line 172:
{def multrepl_rex
{def multrepl_rex.rec ▼
{if {A.empty? :rules}▼
then :word▼
{S.replace_one {W.first {A.first :rules}}▼
by {W.last {A.first :rules}}▼
in :word }▼
{lambda {:word :rules}
{
-> multrepl_rex
{multrepl_rex
abracadabra
{A.new
aA aB a_ aC aD // first "a", second "a", fourth "a", fifth "a"
bE // first "b"
r_ rF // second "r"
_r _a // restore first "r" and third "a"
}}
-> AErBcadCbFD
(AErBcadCbFD)
|