14
15
16:- module(transform_anonymous, [
17 transform_anonymous/2 18 ]).
29transform_anonymous(TermIn, TermOut) :-
30 transform_anonymous(TermIn, TermOut, [], _).
31
32
33transform_anonymous(Var, Var, Map, Map) :-
34 var(Var),
35 !.
36
37transform_anonymous(nodeID('$VAR'(LocalID)), nodeID(GlobalID), MapIn, MapOut) :-
38 !,
39 ( member((LocalID, GID), MapIn) ->
40 GlobalID = GID,
41 MapOut = MapIn
42 ;
43 GlobalID is random(1000000000000000000),
44 MapOut = [(LocalID, GlobalID)|MapIn]
45 ).
46
47transform_anonymous([], [], Map, Map) :-
48 !.
49
50transform_anonymous([H1|T1], [H2|T2], MapIn, MapOut) :-
51 !,
52 transform_anonymous(H1, H2, MapIn, MapTemp),
53 transform_anonymous(T1, T2, MapTemp, MapOut).
54
55transform_anonymous(Term, Term, Map, Map) :-
56 Term =.. [Term],
57 !.
58
59transform_anonymous(Term1, Term2, MapIn, MapOut) :-
60 !,
61 Term1 =.. List1,
62 transform_anonymous(List1, List2, MapIn, MapOut),
63 Term2 =.. List2
Transform Anonymous Individuals