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 19:54, 28 July 2022
, 1 year ago→{{header|JavaScript}}
m (→Python) |
|||
Line 272:
// the nth instances of various characters.
s => mapAccumL(
(a, c) => c in
const ds = a[c];
return 0 < ds.length ? [
Object.assign(a, {[c]: ds.slice(1
] :
})() : [a, c]
)(
|