Execute a Markov algorithm: Difference between revisions

fix bug
(Added zkl)
(fix bug)
Line 3,565:
 
=={{header|zkl}}==
<lang zkl>fcn parseRuleSet(lines){
fcn parseRuleSet(lines){
if(vm.numArgs>1) lines=vm.arglist; // lines or object
ks:=L(); vs:=L();
foreach line in (lines){
if(line[0]=="#") continue; // nuke <comment>
pattern,replacement:=line.splitreplace(" -> \t",1).apply("strip ");
.split(" -> ",1).apply("strip");
ks.append(pattern); vs.append(replacement);
}
Line 3,593:
<lang zkl>ruleSet:=parseRuleSet("# This rules file is extracted from Wikipedia:",
"# http://en.wikipedia.org/wiki/Markov_Algorithm",
"A \t-> apple\tapple", "B -> bag", "S -> shop", "T -> the",
"the shop -> my brother", "a never used -> .terminating rule");
ruleSet.println();
Anonymous user