Execute a Markov algorithm: Difference between revisions

Content added Content deleted
m (→‎{{header|Pascal}}: some correction)
Line 4,907: Line 4,907:
end
end


def morcov(ruleset, input_data)
def marcov(ruleset, input_data)
rules = setup(ruleset)
rules = setup(ruleset)
while (matched = rules.find { |match, replace, term|
while (matched = rules.find { |match, replace, term|
Line 4,928: Line 4,928:
EOS
EOS


puts morcov(ruleset1, "I bought a B of As from T S.")
puts marcov(ruleset1, "I bought a B of As from T S.")


ruleset2 = <<EOS
ruleset2 = <<EOS
Line 4,940: Line 4,940:
EOS
EOS


puts morcov(ruleset2, "I bought a B of As from T S.")
puts marcov(ruleset2, "I bought a B of As from T S.")


ruleset3 = <<EOS
ruleset3 = <<EOS
Line 4,956: Line 4,956:
EOS
EOS


puts morcov(ruleset3, "I bought a B of As W my Bgage from T S.")
puts marcov(ruleset3, "I bought a B of As W my Bgage from T S.")


ruleset4 = <<EOS
ruleset4 = <<EOS
Line 4,989: Line 4,989:
EOS
EOS


puts morcov(ruleset4, "_1111*11111_")
puts marcov(ruleset4, "_1111*11111_")


ruleset5 = <<EOS
ruleset5 = <<EOS
Line 5,012: Line 5,012:
EOS
EOS


puts morcov(ruleset5, "000000A000000")</syntaxhighlight>
puts marcov(ruleset5, "000000A000000")</syntaxhighlight>


{{out}}
{{out}}
Line 5,022: Line 5,022:
00011H1111000
00011H1111000
</pre>
</pre>



=={{header|Rust}}==
=={{header|Rust}}==