[m-rev.] diff: term.m cleanup

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Aug 31 08:51:57 AEST 2009


library/term.m:
	Fix programming style and typos.

Zoltan.

cvs diff: Diffing .
Index: term.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/term.m,v
retrieving revision 1.131
diff -u -b -r1.131 term.m
--- term.m	3 Apr 2008 05:26:47 -0000	1.131
+++ term.m	29 Aug 2009 19:37:15 -0000
@@ -1055,19 +1055,22 @@
 
 %-----------------------------------------------------------------------------%
 
-apply_substitution(V @ variable(Var, _), Substitution, Term) :-
+apply_substitution(Term0, Substitution, Term) :-
+    (
+        Term0 = variable(Var, _),
     ( map.search(Substitution, Var, Replacement) ->
         Term = Replacement
     ;
-        Term = V
+            Term = Term0
+        )
+    ;
+        Term0 = functor(Name, Args0, Context),
+        apply_substitution_to_list(Args0, Substitution, Args),
+        Term = functor(Name, Args, Context)
     ).
-apply_substitution(functor(Name, Args0, Context), Substitution,
-         functor(Name, Args, Context)) :-
-    apply_substitution_to_list(Args0, Substitution, Args).
 
 apply_substitution_to_list([], _Substitution, []).
-apply_substitution_to_list([Term0 | Terms0], Substitution,
-        [Term | Terms]) :-
+apply_substitution_to_list([Term0 | Terms0], Substitution, [Term | Terms]) :-
     apply_substitution(Term0, Substitution, Term),
     apply_substitution_to_list(Terms0, Substitution, Terms).
 
@@ -1076,7 +1079,7 @@
 init_var_supply(var_supply(0)).
 
 create_var(var_supply(V0), var(V), var_supply(V)) :-
-    % We number variables using sequential numbers,
+    % We number variables using sequential numbers.
     V = V0 + 1.
 
 %------------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list