14 ms·
And yet another short, functional solution: pairs = (>>= \ ~(x:xs) -> map ((,) x) xs) . init . tails EDIT: Or as a list comprehension: pairs xs = con
by FalconNL 15y ago
And yet another short, functional solution:
pairs = (>>= \ ~(x:xs) -> map ((,) x) xs) . init . tails
EDIT: Or as a list comprehension:
pairs xs = concat [map ((,) h) t | (h:t) <- tails xs]