
22 Oct
2007
22 Oct
'07
11:22 a.m.
Neil Mitchell wrote:
...Also remember that p may be arbitrarily expensive, while a test for an empty list is cheap. In the particular case of words, p (i.e. isSpace) is very expensive... A reasonable level of optimisation for this function would be that the predicate is invoked at most once on each character. Since its easy to do, it would be a shame not to. The other things are all "small", compared to the predicate whose cost is unknown.
Yes, that makes sense. That is the main issue. Though here it's not much harder to optimize away the extra empty list tests, also. Thanks, Yitz