Handbook
Glossary
wrap-lines ( string width -- newlines )
String word wrapping
Next:
wrap-string ( string width -- newstring )
Vocabulary
wrap
.
strings
Inputs
string
a
string
width
an
integer
Outputs
newlines
sequence of strings
Word description
Given a
string
, divides it into a sequence of lines where each line has no more than
width
characters, unless there is a word longer than
width
. Linear whitespace between words is converted to a single space.
Definition
USING:
kernel
sequences
wrap
wrap.strings.private
;
IN:
wrap.strings
:
wrap-lines
( string width -- newlines )
[
wrap-split-lines
]
keep
[
wrap
join-elements
]
curry
map!
concat
;