13 Oct
2004
13 Oct
'04
8:13 a.m.
Question 2 ---------- How to arrange the above `lazy' output?
Your function addToSPair addToSPair :: Char -> (String, String) -> (String, String) addToSPair c (xs, ys ) = (c:xs, ys ) does a strict pattern match on the pair constructor. It needs to know that its second argument is a pair before it produces anything of its result. If you use a lazy pattern match addToSPair :: Char -> (String, String) -> (String, String) addToSPair c ~(xs, ys ) = (c:xs, ys ) instead, it doesn't need to evaluate this argument immediately. Regards, Sander