diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2014-10-07 10:58:48 +0200 |
---|---|---|
committer | Aleš Smodiš <aless@guru.si> | 2015-08-11 14:26:00 +0200 |
commit | 99db41ecfb75d4e264b8a7381eac6776ec27973b (patch) | |
tree | 805c00f946cac76bcb74ef3cd77bdd523fa7511e /prolog | |
parent | bc084afb2b171cfc0b1c77a529211d7885c7cb6b (diff) |
Add some ad-hoc test code to prolog/util.py
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) |