> getAorB 6 5 [5,5..]
While you may not care about a contrived example like this, it does imply that your function scans the list once, searching for the first element, and once again, searching for the second. Note that it scans twice even if the first element was found, because of the pattern:
> f (Just a) Nothing = a > f Nothing (Just a) = a
The following pattern behaves better:
> f (Just a) _ = a > f _ (Just a) = a
and halts on:
> getAorB 5 6 [5,5..]
I don't think there is a way to get proper laziness by using get twice. I suggest implementing getAorB using explicit recursion, which is probably how you implemented get.
-Arjun
_______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell