RosettaCodeData/Task/Execute-a-Markov-algorithm/APL/execute-a-markov-algorithm.apl

21 lines
629 B
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

markov{
trim{(~(\(\))⎕UCS 9 32)/}
rules(~rules⎕UCS 10 13)rules80 ¯1 ⎕MAP
rules('#'¨rules)/rules
rules{
norm' '@(9=⎕UCS)
spos' -> 'norm
pattrim spos
repltrim(spos+2)
term'.'=repl
term pat(termrepl)
}¨rules
apply{
0=rule/¨(2¨)¨:
term pat repl[rule]
idx(pat)-1
(~term)(idx),repl,(idx+pat)
}
rules apply
}