online advertising

Tuesday, June 2, 2015

Haskell 99 Problem 7

Problem

Please find the problem here.

Solution:

Please see the solution as follow:

My original solution involved using the ++ operator, which is not optimal. Now I am using difference list. The problem with list is whenever a list a created, it cannot be appended anymore. So instead of having a list created, we create a function to produce a list. that function takes the suffix of the list as an argument and produce the list as a result. That avoid creating the list and postpone it to the time until we actually want the list. Now composing these functions are concatenation and that takes constant time! .

No comments :

Post a Comment