
On Thu, Jul 29, 2004 at 01:57:51PM +0200, Marcin 'Qrczak' Kowalczyk wrote:
W liście z czw, 29-07-2004, godz. 13:39 +0200, Tomasz Zielonka napisał:
Have you looked at List.unfoldr? It's even more general.
unfoldr :: (b -> Maybe (a, b)) -> b -> [a]
And when we finally find a very general solution, the specific case of "split colon-separated fields" requires some thought and three lines of code using higher order functions and pattern matching, instead of just splitSep (== ':') line :-)
Make simple things easy, complex things possible. Concentrate on the first part. Generalize only if it doesn't make the common simple case harder. After all, one always can write a complex splitting function by hand. The simple version doesn't have to cover all possible generalizations, only those which don't disturb common cases.
I agree. I often found that writing a splitting function with unfoldr is a bit cumbersome. Best regards, Tom -- .signature: Too many levels of symbolic links