Question: 4. Write a Haskell function reorder :: [a] => [a] such that reorder xs returns the list obtained by switching the order of suc- cessive

 4. Write a Haskell function reorder :: [a] => [a] such

4. Write a Haskell function reorder :: [a] => [a] such that reorder xs returns the list obtained by switching the order of suc- cessive pairs of elements of xs (i.e., the first and second items are switched, the third and fourth items are switched, and so on). When xs has an odd number of elements, the last item retains its original position. For example, the function should have the following behavior: *Main> reorder [10,20,30,40,50,60,70] [20,10,40,30,60,50,70] *Main > reorder ["one","two","three","four"] ["two","one","four", "three"]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!