2 #Simple Markov chain Dissociated Press implementation
3 #adapted from http://cm.bell-labs.com/cm/cs/tpop/markov.pl
9 my @
@w = "\n" xx
$n; # initial state
11 for $*ARGS
.comb
{ # read each word of input
13 @
@w.push: $_; @
@w.shift; # advance chain
15 %s{@
@w}.push: "\n"; # add tail
18 while ($_ = %s{@
@w}.pick
).say {
19 last if /\n/ or $o++ >= $m;
20 @
@w.push: $_; @
@w.shift; # advance chain