tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 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