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 17:39, 28 July 2022
, 1 year ago→{{header|JavaScript}}
Line 237:
// A string defined by replacements specified for
// the nth instances of various characters.
s =>
ds = ruleMap[c];▼
return [▼
Object.assign(a, {[c]: 1 + i}),▼
i < ds.length ? (▼
ds[i] || c▼
) : c▼
];▼
return mapAccumL(go)({})([...s])[1].join("");▼
// ---------------------- TEST -----------------------
|