Execute a Markov algorithm: Difference between revisions

Add Déjà Vu example
(Add Déjà Vu example)
Line 1,430:
000000A000000
00011H1111000</pre>
 
=={{header|Déjà Vu}}==
This implementation expect the initial text on the command line and the ruleset on STDIN (the ruleset is ended by an empty line).
<lang dejavu>(remove-comments) text:
]
for line in text:
if and line not starts-with line "#":
line
[
 
(markov-parse) text:
]
for line in text:
local :index find line " -> "
local :pat slice line 0 index
local :rep slice line + index 4 len line
local :term starts-with rep "."
if term:
set :rep slice rep 1 len rep
& pat & term rep
[
 
markov-parse:
]
while dup input:
pass
[
(markov-parse) (remove-comments)
 
(markov-tick) rules start:
for rule in copy rules:
local :pat &< rule
local :rep &> dup &> rule
local :term &<
local :index find start pat
if < -1 index:
)
slice start + index len pat len start
rep
slice start 0 index
concat(
return term
true start
 
markov rules:
true
while:
not (markov-tick) rules
 
markov markov-parse</lang>
 
=={{header|Go}}==
Anonymous user