Subject: Locating Singleton Variables

From: "Douglas R. Miles" <[email-masked]>
Date: Mon, 27 Nov 2000 14:16:25 -0800

What would be the best way to locate singleton variables? 

So far...

vars_info(Clause,[],[],[]):-ground(Clause).
vars_info(Clause,AllVars,EachVar,Singletons):-copy_term(Clause,ClauseCopy),
 
term_to_atomlist(ClauseCopy,ClauseCopiedList),numbervars(ClauseCopiedList),
   findall('$VAR'(N),member('$VAR'(N),ClauseCopiedList),AllVars),
   sort(AllVars,EachVar),
    ....
	What should I do to find Singletons?
	Most likely I am going about this all wrong.

term_to_atomlist([Var],[Var]):-(var(Var);atomic(Atom)),!.
term_to_atomlist([TERM],[H|T]):-!,TERM=..[H|Args],term_to_atomlist(Args,T),!
.
term_to_atomlist([H|T],List):-!,term_to_atomlist([H],HList),term_to_atomlist
(T,TList),append(HList,TList,List).
term_to_atomlist(Term,AtomList):-!,conv(TermList,Term),term_to_atomlist(Term
List,AtomList). 

conv([X|T],(X,R)) :- T \== [],!,conv(T,R).
conv([X],(X))

Thank you in advance,

Douglas Miles