15Sep/092
Haskell While Loop
In the past week, while working on three completely unrelated Haskell projects, I have found myself in need of a while loop. So I came up with this one:
Hoogle shows no functions with that type signature, and I couldn't find anything in the documentation that seemed to fit the bill. This seems like a rather fundamental function for getting stuff done, is there something I'm missing?
EDIT: The most code-golfed version I have yet come up with is while p a = p >>= flip when (a >> while p a) can anyone improve on that?













September 15th, 2009 - 22:20
Maybe
is a little better.
September 15th, 2009 - 22:33
True. I hadn’t thought of that.
seems to be even more concise in the long run: