I am trying a few problems (at Spoj) in Haskell and I have stumbled on quite a few which have input of the form:
testcase_1
testcase_1_continued
testcase_2
testcase_2_continued
or
testcase_1 testcase_1_continued
...
As you can see, one cannot solve this by just using words or lines on the input and then mapping the solver function to get something like
[solver test1, solver test2, ...]
One should use a function with two arguements, which are two list elements, one after the other, and get:
[solver test1 test1continued, solver test2 test2continued, ...]
So I would be pleased to find an analogous function to map which applies a function 2 arguments at a time.I have not been able to find anything on Hoogle, and however easy it would be to write such a function, I am looking for a more general approach to the problem.Or, if my approach(of insisting on map) is definitely wrong, one could also point me to the right direction.
Edit:
I actually found it really useful to implement a function map2 which maps a function to a list, only it works two arguments a time:
map2 f [a,b,c,d] ==> [f a b, f c d]
Use chunksOf.