home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / prolog / 1647 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  935 b 

  1. Path: sparky!uunet!icd.ab.com!iccgcc.decnet.ab.com!baechtel
  2. From: baechtel@iccgcc.decnet.ab.com
  3. Newsgroups: comp.lang.prolog
  4. Subject: Help with C-Prolog, Please.
  5. Message-ID: <1992Sep3.164303.8798@iccgcc.decnet.ab.com>
  6. Date: 3 Sep 92 16:43:03 EST
  7. Lines: 32
  8.  
  9.  
  10.  
  11.     In C-Prolog 1.5, is there anyway to get the name of a variable
  12. in a term?
  13.  
  14.     Specifically, If I write:
  15.  
  16. read(Term, Vars) :-
  17.     read(Term),
  18.     functor(Term,F,A),
  19.     getvars(Term,A,Vars,[]).
  20.  
  21. getvars(Term,0,Varlist,Varlist).
  22.  
  23. getvars(Term,A,Vars,Varlist) :-
  24.     arg(A,Term,Arg),
  25.     ( var(Arg), Vars1 = [Arg | Varlist]; Vars1 = Varlist),
  26.     A1 is A-1,
  27.     getvars(Term,A1,Vars,Vars1).
  28.  
  29. If I execute read(Term,Vars) and my input is: "X is Y.",
  30. Term = "X is Y" and Vars = [_15,_16].
  31.  
  32. Is there anyway to get Vars=[X,Y]?
  33. I don't understand how to get the name of the Variable instead of its
  34. reference.
  35.  
  36. Can anyone suggest code that will work in C-Prolog?
  37.  
  38. Thanks in advance.
  39. .
  40.  
  41.