Anonymous user
Markov chain text generator: Difference between revisions
m
→{{header|REXX}}: elided the need for the RAND function, changed a comment..
(Edited my Python to conform to standards a bit better.) |
m (→{{header|REXX}}: elided the need for the RAND function, changed a comment..) |
||
Line 920:
sw = linesize() - 1 /*get usable linesize (screen width). */
$= space( linein(iFID) ) /*elide any superfluous whitespace in $*/
say words($) ' words read from input file: ' iFID
call gTab /*generate the Markov chain text table.*/
Line 926 ⟶ 925:
call show /*display formatted output and a title.*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
gTab: @.=; do j=1 for words($)-ord /*keep processing until words exhausted*/
p= subword($,
end /*j*/
#= j-1 /*define the number of prefixes. */
Line 938 ⟶ 934:
/*──────────────────────────────────────────────────────────────────────────────────────*/
gTxt: mc=; do until words(mc)>=fin /*build Markov chain text until enough.*/
y= subword(
s= @.y; w= words(s) /*get a suffix for a word set; # wprds.*/
if w>1 then s= word(s,
mc= mc y s /*add a prefix and suffix to the output*/
end /*until*/
|