Execute a Markov algorithm: Difference between revisions
→{{header|jq}}: tidy
(→{{header|jq}}: simplify) |
(→{{header|jq}}: tidy) |
||
Line 2,839:
end );
# applyRules applies $rules to . recursively,
# where $rules is the set of applicable rules in the form of an array-of-triples.
# Input and output: a string
# The inner function has arity-0 for efficiency
▲def chain( $rules ):
def apply:
| first(
| if $c[1] ==
then (apply | .
{stop: false, string: .} | apply
def proceed:
Line 2,867 ⟶ 2,866:
| range(0; $tests|length) as $ix
| $tests[$ix]
| " \(.)\n=>\(
proceed</lang>
|