Article View: comp.lang.prolog
Article #768Help with C-Prolog, Please.
From: baechtel
Date: Thu, 03 Sep 1992 21:43
Date: Thu, 03 Sep 1992 21:43
31 lines
973 bytes
973 bytes
In C-Prolog 1.5, is there anyway to get the name of a variable
in a term?
Specifically, If I write:
read(Term, Vars) :-
read(Term),
functor(Term,F,A),
getvars(Term,A,Vars,[]).
getvars(Term,0,Varlist,Varlist).
getvars(Term,A,Vars,Varlist) :-
arg(A,Term,Arg),
( var(Arg), Vars1 = [Arg | Varlist]; Vars1 = Varlist),
A1 is A-1,
getvars(Term,A1,Vars,Vars1).
If I execute read(Term,Vars) and my input is: "X is Y.",
Term = "X is Y" and Vars = [_15,_16].
Is there anyway to get Vars=[X,Y]?
I don't understand how to get the name of the Variable instead of its
reference.
Can anyone suggest code that will work in C-Prolog?
Thanks in advance.
.
Technical Details
Message-ID:
<1992Sep3.164303.8798@iccgcc.decnet.ab.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!icd.ab.com!iccgcc.decnet.ab.com!baechtelShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!icd.ab.com!iccgcc.decnet.ab.com!baechtel From: baechtel@iccgcc.decnet.ab.com Newsgroups: comp.lang.prolog Subject: Help with C-Prolog, Please. Message-ID: <1992Sep3.164303.8798@iccgcc.decnet.ab.com> Date: 3 Sep 92 16:43:03 EST Lines: 32