
Before I write the code I like to be able to quantify my expected result. But I am having hard time quantifying my expected result for alternative approaches in Haskell. I would appreciate any comments from experienced Haskell-ers on this problem: Suppose I have a big list of integers and I like to find the first two that add up to a number, say 10. One approach is to put the numbers in the map as I read them and each step look for the 10-x of the number before going on to the next value in the list. Alternatively, I am trying to see if I it make sense to covert the list to a series of computations that each is looking for the 10-x in the rest of the list (running them in breath first search). I like to find out sanity of using the Applicative/Alternative class's (<|>) operator to set up the computation. So each element of the list (say x) is recursively converted to a computation to SearchFor (10 - x) that is (<|>)-ed with all previous computation until one of the computations returns the pair that add up to 10 or all computation reach end of the list. Does the approach make any sense? What kind of overhead should I expect if I convert the numbers to a computation on the list? In one case I would have a number in a map and in the other I would have a number in a computation over a list. How do I quantify the overheads? Thanks, Daryoush