diff options
Diffstat (limited to 'rosetta/lines.neb')
| -rw-r--r-- | rosetta/lines.neb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/rosetta/lines.neb b/rosetta/lines.neb new file mode 100644 index 0000000..45a6a6f --- /dev/null +++ b/rosetta/lines.neb @@ -0,0 +1,16 @@ + +(func adjust (text width) + (def lines (list)) + (def word "") + (for-each (split text " ") + (branch + ((eq? 0 (length word)) (redef word _item_)) + ((<= (+ (length word) 1 (length _item_)) width) + (redef word (concat word " " _item_))) + (#true + (block + (redef lines (append lines word)) + (redef word _item_))))) + (if (not (eq? 0 (length word))) + (append lines word) + lines)) |
