标签: list haskell tuples
如何在没有递归的情况下从列表中获取连续对(元组)的列表?
例如:[1, 2, 3, 4]为[(1, 2), (2, 3), (3, 4)]
[1, 2, 3, 4]
[(1, 2), (2, 3), (3, 4)]
答案 0 :(得分:11)
\xs -> zip xs $ tail xs或zip <*> tail。
\xs -> zip xs $ tail xs
zip <*> tail