Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site nbs-amrf.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!umcp-cs!nbs-amrf!hopp From: hopp@nbs-amrf.UUCP (Ted Hopp) Newsgroups: net.lang.prolog Subject: Definition of 'numbervars/3' Message-ID: <447@nbs-amrf.UUCP> Date: Tue, 5-Mar-85 13:52:26 EST Article-I.D.: nbs-amrf.447 Posted: Tue Mar 5 13:52:26 1985 Date-Received: Thu, 7-Mar-85 04:16:19 EST Organization: National Bureau of Standards Lines: 37 I recently obtained a listing of Dave Warren's WARPLAN planner and put it up on our system, running C-Prolog 1.3. Everything went smoothly except for a predicate "numbervars/3", which was evidently part of the prolog he was using (DEC-10 Prolog?), but is not part of our Prolog. I did find a description of it, which described it something like this (this is off the top of my head): numbervars(T,N,M) Binds all variables in T to special terms such that the variables print as consecutive integers from N to M. I defined a numbervars and it seems to work, but I have no idea if it is right. My definition is: numbervars(T,N,N) :- atomic(T),!. numbervars(T,N,M) :- var(T),!,M is N+1,T=M. numbervars([H|T],N,M) :- !,numbervars(H,N,M1),numbervars(T,M1,M). numbervars(T,N,M) :- T=..[_|Args],!,numbervars(Args,N,M). That is, I bind each variable in T to an integer. Is this, for practical purposes, different that binding to "special terms" that print as integers? In particular, the goal: numbervars(X,0,1),numbervars(Y,0,1),X=Y. succeeds with my definition; does it with the built-in numbervars on those Prologs that have it? As a secondary question, if my definition is operationally correct, is there a more efficient definition? WARPLAN seems to spend a lot of time numbering variables, and it would be nice if this were as efficient as possible. -- Ted Hopp {seismo,umcp-cs}!nbs-amrf!hopp