aboutsummaryrefslogtreecommitdiff
path: root/rosetta/lines.neb
blob: 45a6a6f6d434bd08fdd6614696f7b25cec0e73d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))