Meta Predicates and Variables in SWI Prolog
From: Michael David Pedersen (mdp_at_cs.auc.dk)
Date: 03/30/04
- Next message: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Previous message: Matthew Huntbach: "Re: Mainstreaming Prolog a Pragmatic Approach?"
- Next in thread: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Reply: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Previous message: Matthew Huntbach: "Re: Mainstreaming Prolog a Pragmatic Approach?"
- Next in thread: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Reply: Bart Demoen: "Re: Meta Predicates and Variables in SWI Prolog"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|