StackOverflow is not a service where people will just write code for you.
(StackOverflow不是人们只为您编写代码的服务。)
You have to show your attemts or any effort that you applied to solve the task and demonstrate us problems that you've encountered on that way. (您必须展示自己为解决该任务而做出的努力或付出的努力,并向我们展示您在此过程中遇到的问题。)
If you just ask people to solve your task, they'll get angry at you (-3 score of this question states exactly that), and your question will be closed.
(如果您只是要求别人解决您的任务,他们会生您的气(这个问题的分数为-3恰恰说明了这一点),您的问题将被关闭。)
So make sure you demonstrate enough effort in solving a task when asking about it here. (因此,在此处询问任务时,请确保您表现出足够的精力来解决任务。)
BTW, I'll give you a hint:
(顺便说一句,我给你一个提示:)
pairUp :: [a] -> [(a, a)]
pairUp [] = [] -- obvious case
pairUp [x] = error "Odd-length list!"
pairUp (x:y:xs) = ...
You have to complete the last case.
(您必须完成最后一个案例。)
Here you have first two elements x
and y
, and also the tail list of all other elements. (在这里,您有前两个元素x
和y
,还有所有其他元素的尾部列表。)
You have to combine the first two elements in a pair and also process the tail in the same way. (您必须将成对的前两个元素组合在一起,并以相同的方式处理尾部。)
You will need an understanding recursion to accomplish the task. (您将需要理解递归才能完成任务。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…