Tuesday, June 2, 2015

Haskell 99 Problem 5

Problem:

Please find the problem here.

Solution:

Please see the solution as follow:

Accumulator pattern again, nothing too special. It is interesting, however, to note we can interpret a program written using the accumulator pattern in terms of iteration as follow

myreverse' [1,2,3] [] = myreverse' [2,3] [1] = myreverse' [3] [2,1] = myreverse' [] [3,2,1] = [3,2,1]

The code would not be as easy to interpret otherwise.

No comments :

Post a Comment