Saturday, August 21, 2010

Word Wrapping in Haskell

Prompted by a question on haskell-cafe, here's a relatively concise word-wrapping implementation I wrote:

Update: Thanks to Yitz in the comments for pointing out that "any isSpace line" should be "any isSpace beforeMax"

3 comments:

  1. This diverges if any word is longer than the line length. See my reddit comment http://www.reddit.com/r/haskell/comments/d3ybw/word_wrapping_in_haskell/

    ReplyDelete
  2. That's a minor bug, just change "any isSpace line" to "any isSpace beforeMax".

    ReplyDelete