diff options
Diffstat (limited to 'prolog')
-rw-r--r-- | prolog/util.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/prolog/util.py b/prolog/util.py index 438c068..85589b5 100644 --- a/prolog/util.py +++ b/prolog/util.py @@ -143,3 +143,15 @@ def map_vars(before, after, line, rule): mapping_all = {k: v for k, v in mapping.items()} mapping_all.update(more_mapping) yield mapping_all + +# Basic sanity check. +if __name__ == '__main__': + rule = tokenize('dup([H|T], [H1|T1]) :- dup(T1, T2). ') + line = tokenize('dup([H|T], [H1|T1]) :-') + before = tokenize("dup([A0|A1], [A2|A3])") + after = tokenize("dup([A0|A1], [A5, A4|A3])") + var_names = rename_vars(before) + rename_vars(after, var_names) + + for mapping in map_vars(before, after, line, rule): + print(mapping) |