Markov chain text generator: Difference between revisions
Content deleted Content added
Added missing <lang Nim> |
Changed the way to display the text splitting it to avoid lines longer than a limit. |
||
Line 939:
result = output[0..<outputSize].join(" ")
const MaxLineSize = 100
randomize()
var start = 0
while start < result.len:
var idx = if start + MaxLineSize <= result.high: result.rfind(' ', start, start + MaxLineSize)
else: result.high
if idx < 0: idx = result.high
echo result[start..idx]
start = idx + 1</lang>
{{out}}
<pre>ground was carpeted with them. There were big yellow and white and blue and purple blossoms, besides
great clusters of scarlet poppies, which were so brilliant in color they almost dazzled Dorothy's
eyes. Aren't they beautiful? the girl asked, as she breathed in the spicy scent of the flowers, and
here they laid her gently on the forehead. Where her lips touched the girl they left a round,
shining mark, as Dorothy found out soon after. The road to the City of Emeralds. Perhaps Oz will
help you. Where is this great spider of yours now? asked the Tin Woodman.</pre>
=={{header|Perl}}==
|