From 99db41ecfb75d4e264b8a7381eac6776ec27973b Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Tue, 7 Oct 2014 10:58:48 +0200 Subject: Add some ad-hoc test code to prolog/util.py --- prolog/util.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'prolog') 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) -- cgit v1.2.1