diff options
| author | mryouse | 2023-06-03 20:22:18 +0000 |
|---|---|---|
| committer | mryouse | 2023-06-03 20:22:18 +0000 |
| commit | 7b7bf727da3250907284368b98b0083a4b4e2386 (patch) | |
| tree | 34802caea5181dc0fb97992746ab99b080448418 /rosetta/lines.neb | |
initial commit
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)) |
