Gary Johnson wrote: > On 2007-08-16, [EMAIL PROTECTED] wrote: > >> On Wed, Aug 15, 2007 at 10:55:07AM -0700, Gary Johnson wrote: >> >> >>> Oh! I misunderstood. Thanks for the explanation. Yes, that would be >>> a nice alternative to the current algorithm. >>> >> I recently wrote an implementation of the optimal line breaking >> algorithm (in Ruby). If you are interested, the file is located here, >> with a small piece of test code at the end: >> http://lissujaismo.net/rbpar/rbpar_engine.rb >> >> You can run the test code by saying "ruby rbpar_engine.rb". >> > > I tried that on a system running Red Hat Enterprise Linux WS release > 4 and > > $ which ruby > /usr/bin/ruby > $ /usr/bin/ruby -v > ruby 1.8.1 (2003-12-25) [i386-linux-gnu] > > The command ran without generating any error messages, but it didn't > generate anything else, either. I don't know Ruby, but I expected > to see the contents of the 'words' string formatted to a width of 70 > columns on stdout. > > Regards, > Gary > > For those who are ML-savvy, I've attached SML code for optimal line breaking (optimal as defined by TeX's 'sum of cubes' rule). This code uses memoization in a very simple but efficient way. Actually, the attachment contains two functions for doing it, one which is a brute-force exponential search (linebreak_simple), and the other uses memoization (linebreak). The upshot is that optimal line breaking is only about 40 lines of code (in SML). Note that this code doesn't do the other fancy things that gq does in vim.
-- Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
linebreak.sml
Description: application/smil
