Determine if a string has all unique characters: Difference between revisions

m
Line 567:
const duplicatedCharIndices = s => {
const
duplicationsduplicates = filter(g => 1 < g.length)(
groupBy(on(eq)(snd))(
sortBy(comparing(snd))(
Line 574:
)
);
return 0 < duplicationsduplicates.length ? Just(() => {
constfanArrow(compose(snd, fst))(map(fst))(
firstCase =sortBy(comparing(compose(fst, fst)))(
sortBy(comparing(compose(fst, fst)))(duplicates
duplications)[0]
)
) : Nothing();
return Just(Tuple(firstCase[0][1])(
firstCase.map(fst)
));
})() : Nothing()
};
 
Line 652 ⟶ 648:
// eq (==) :: Eq a => a -> a -> Bool
const eq = a => b => a === b;
 
// fanArrow (&&&) :: (a -> b) -> (a -> c) -> (a -> (b, c))
const fanArrow = f =>
// Compose a function from a simple value to a tuple of
// the separate outputs of two different functions.
g => x => Tuple(f(x))(g(x));
 
// filter :: (a -> Bool) -> [a] -> [a]
Line 702 ⟶ 704:
xs.length
) : Infinity;
 
// map :: (a -> b) -> [a] -> [b]
const map = f => xs =>
(Array.isArray(xs) ? (
));xs
) : firstCasexs.split('')).map(fstf);
 
// maybe :: b -> (a -> b) -> Maybe a -> b
9,659

edits