Split a character string based on change of character: Difference between revisions

m
(→‎JavaScript ES6: Added a variant expressed in terms of a general `span` function.)
Line 1,454:
const i = xs.findIndex(x => !p(x));
 
return -1 !== i ? ([
[xs.slice(0, i),
xs.slice(i)
] : [xs, []];
) : [xs, []];
};
 
9,655

edits