diff options
| author | mryouse | 2022-08-02 02:16:38 +0000 |
|---|---|---|
| committer | mryouse | 2022-08-02 02:16:38 +0000 |
| commit | ee509e05746731b12afe64bfe34284b119f6b4ae (patch) | |
| tree | 3a7e2e2ea668a99ab979e5852eedb661d9723085 /rosetta/lines.neb | |
| parent | 7300580eb3aacfe1b67918fb20259e3ec26559c2 (diff) | |
exercises
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)) |
