34 lines
1,022 B
Text
34 lines
1,022 B
Text
import util.
|
|
|
|
go =>
|
|
text(1,Text),
|
|
foreach(LineWidth in [60,80])
|
|
println(lineWidth=LineWidth),
|
|
println(wrap(Text,LineWidth)),
|
|
nl
|
|
end,
|
|
nl.
|
|
|
|
wrap(Text,LineWidth) = Wrapped =>
|
|
Words = Text.split(),
|
|
Wrapped = Words[1],
|
|
SpaceLeft = LineWidth - Wrapped.len,
|
|
foreach(Word in Words.tail)
|
|
WordLen = Word.length,
|
|
if (WordLen + 1) > SpaceLeft then
|
|
Wrapped := Wrapped ++ "\n" ++ Word,
|
|
SpaceLeft := LineWidth - WordLen
|
|
else
|
|
Wrapped := Wrapped ++ " " ++ Word,
|
|
SpaceLeft := SpaceLeft - WordLen - 1
|
|
end
|
|
end.
|
|
|
|
text(1,"Lorem ipsum dolor sit amet, consectetur adipiscing
|
|
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
|
|
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
|
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
|
|
dolor in reprehenderit in voluptate velit esse cillum dolore eu
|
|
fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
|
proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
laborum.").
|