Meta Predicates and Variables in SWI Prolog

From: Michael David Pedersen (mdp_at_cs.auc.dk)
Date: 03/30/04


Date: Tue, 30 Mar 2004 12:49:04 +0200

Hi all,

I am having troube using the meta predicate apply(Term, List) in the
following context.

rel(a, b, c).
rel(d, e, g).
apply(rel, List)

where List should be e.g. [A, B, _]. This should give the results A=a, B=b
and A=d, B=d.

However the list is being constructed at runtime and looks like ['A', 'B',
'_']. I thus need to convert this to a list of atoms as needed in the apply
predicate. I have tried using the term_to_atom(Term, Atom) predicate, but
this does not seem to work for upper case terms:

term_to_atom('A', Atom).

replies with Atom = '\'A\'' instead of Atom=A. However, it works fine for
lower case characters. I get similar results using the name predicate.

I must be overlooking something, so any suggestions on how to do the
convertion from character to atom will be greatly appreciated!
Regards,

Michael David Pedersen



Relevant Pages

  • Urgent: Text extraction from HTML
    ... I need urgent help! ... file in Buffer (as an atom). ... So now somewhere in the Buffer ... So I want to write a predicate samplesuch that it ...
    (comp.lang.prolog)
  • Re: Prolog, memory management and memory leaks
    ... Any atom appearing in the program is referenced by some ... predicate and will not be GC'ed. ... SWI-Prolog does reference-counting on atoms referenced from predicates, ...
    (comp.lang.prolog)
  • Re: listing(+Pred, -Atom)
    ... is there a predicate (e.g. in swi) of this type: ... Atom), where Atom contains the listing for Pred? ...
    (comp.lang.prolog)
  • Re: listing(+Pred, -Atom)
    ... is there a predicate (e.g. in swi) of this type: ... Atom), where Atom contains the listing for Pred? ... how could such a predicate be written? ...
    (comp.lang.prolog)
  • Re: Coextensive properties?
    ... Quine's "Der" operator to reduce a two place predicate such as ". ... context C such that the object ... ... But we must now explicitly relativize this before we can apply the "Der" ... P by an ideal observer who would conform to all clauses of D1." ...
    (sci.logic)