Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,22 @@
|
|||
procedure main(A)
|
||||
rules := loadRules(open(A[1],"r"))
|
||||
every write(line := !&input, " -> ",apply(rules, line))
|
||||
end
|
||||
|
||||
record rule(pat, term, rep)
|
||||
|
||||
procedure loadRules(f)
|
||||
rules := []
|
||||
every !f ? if not ="#" then put(rules,
|
||||
rule(1(trim(tab(find("->"))),move(2),tab(many(' \t'))),
|
||||
(="."|&null), trim(tab(0))))
|
||||
return rules
|
||||
end
|
||||
|
||||
procedure apply(rules, line)
|
||||
s := line
|
||||
repeat {
|
||||
s ?:= tab(find((r := !rules).pat)) || r.rep || (move(*r.pat),tab(0))
|
||||
if (s == line) | \r.term then return s else line := s
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue