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

m
Line 1,251:
// elements equal under (===), such that the
// concatenation of these lists is xs.
0groupBy(a <=> xs.lengthb ?=> (()a =>== {b)(xs);
 
 
// groupBy :: (a -> a -> Bool) [a] -> [[a]]
const groupBy = eqOp =>
// A list of lists, each containing only elements
// equal under the given equality operator,
// such that the concatenation of these lists is xs.
xs => 0 < xs.length ? (() => {
const [h, ...t] = xs;
const [v, r] = t.reduce(
([gpsgs, a], x) => eqOp(x === )(a[0]) ? (
Tuple(gpsgs)([...a, x])
) : Tuple([...gpsgs, a])([x]),
Tuple([])([h])
);
Line 1,262 ⟶ 1,270:
return [...v, r];
})() : [];
 
 
// Tuple (,) :: a -> b -> (a, b)
9,655

edits