Making basis/wrap not try to align the last line
parent
8c4fb753f6
commit
c51a5d7678
|
|
@ -27,7 +27,7 @@ word wrap.">
|
||||||
" " wrap-indented-string
|
" " wrap-indented-string
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
[ "this text\nhas lots\nof spaces" ]
|
[ "this text\nhas lots of\nspaces" ]
|
||||||
[ "this text has lots of spaces" 12 wrap-string ] unit-test
|
[ "this text has lots of spaces" 12 wrap-string ] unit-test
|
||||||
|
|
||||||
[ "hello\nhow\nare\nyou\ntoday?" ]
|
[ "hello\nhow\nare\nyou\ntoday?" ]
|
||||||
|
|
@ -39,3 +39,5 @@ word wrap.">
|
||||||
[ "aaa bb\nccccccc\nddddddd" ] [ "aaa bb ccccccc ddddddd" 6 wrap-string ] unit-test
|
[ "aaa bb\nccccccc\nddddddd" ] [ "aaa bb ccccccc ddddddd" 6 wrap-string ] unit-test
|
||||||
|
|
||||||
\ wrap-string must-infer
|
\ wrap-string must-infer
|
||||||
|
|
||||||
|
[ "a b c d e f\ng h" ] [ "a b c d e f g h" 11 wrap-string ] unit-test
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,10 @@ SYMBOL: line-ideal
|
||||||
] each drop ; inline
|
] each drop ; inline
|
||||||
|
|
||||||
: paragraph-cost ( paragraph -- cost )
|
: paragraph-cost ( paragraph -- cost )
|
||||||
[ head-width>> deviation ]
|
dup lines>> 1list? [ drop 0 ] [
|
||||||
[ tail-cost>> ] bi + ;
|
[ head-width>> deviation ]
|
||||||
|
[ tail-cost>> ] bi +
|
||||||
|
] if ;
|
||||||
|
|
||||||
: min-cost ( paragraphs -- paragraph )
|
: min-cost ( paragraphs -- paragraph )
|
||||||
[ paragraph-cost ] min-by ;
|
[ paragraph-cost ] min-by ;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue