Put adjacent elements in List into Tuples
问题 Given a List of elements: xs = [a, b, c, d, ... z] where a, b, c etc are placeholders for arbitrary values. I want to implement a function adjacents :: [a] -> [(a, a)] that produces adjacentValues = [(a, b), (b, c), (c, d), ... (y, z)] In Haskell, a recursive definition is reasonably concise: adjacents :: [a] -> [(a, a)] adjacents (x:xs) = (x, head xs) : adjacents xs adjacents [] = [] Purescript is a little more verbose: adjacents :: forall a. List a -> List (Tuple a a) adjacents list = case