Re: Beginner's questions
- From: Søren Hansen <sh@xxxxxxxx>
- Date: Thu, 05 May 2005 20:28:50 +0200
On Wed, 04 May 2005 08:00:24 -0700, Brian Hulley wrote:
>> Nevertheless, this is my code so far. Beware, I'm 100% newbie. :-)
>> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>> digit(X) :- member(X, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).
> The above clause is OK, since there is no built-in predicate digit/1.
Right. That one was pretty easy. :-)
>> not(member(c, [a, t, d, o, g, n, t])).
>> not(member(a, [t, d, o, g, n, t])).
>> not(member(t, [d, o, g, n, t])).
>> not(member(d, [o, g, n, t])).
>> not(member(o, [g, n, t])).
>> not(member(g, [n, t])).
>> not(member(n, [t])).
>> r0 = g+t.
>> t = r0 mod 10.
>> c0 = r0 // 10.
>> r1 = c0+o+n.
>> a = r1 mod 100.
>> c1 = r1 // 100.
>> c = c1+d+a.
> None of the above clauses can be asserted, because they conflict with
> Prolog's built-in predicates ie not/1 and =/2 which you can't redefine.
Oh, that's not what I'm trying to do. the "not(member(.." clauses are
supposed to explain to the interpreter, that c is not a member of the
list of a, t, d, o, g, n, and t. That is to say, c does not have the same
value as neither a, t, d, o, g, n, or t.
The rest is supposed to tell the intepreter that r0 equals the sum of g
and t, t equals r0 mod 10, etc..
I really appreciate all your suggestions, but could we stick with my
code? I know it's a piece of sh*te, but I think it'd help me understand.
The digit/1 things are all fine, so let's not worry any more about that.
The way I've understood prolog so far, what I define are a bunch of
truths, and prolog can the use these truths to deduce other truths.
"not(member(c, [a, t, d, o, g, n, t])" was supposed to say that c does not
hold the same value as any of the other constants whose value I'm trying
to find. From what I gather now, this is wrong for two reasons:
1. Prolog thinks I'm trying to redefine not/1. I'm not sure why, or how to
fix it.
2. The member/2 is also wrong, because it's not using the values of the
constants, but rather the constants themselves, which makes the statements
redundant, because of course c is not a. They might hold the same value,
but they're not the same constant. I'm not really sure how to fix this
either.
Thank for your help so far!
--
Salu2, Søren.
.
- Follow-Ups:
- Re: Beginner's questions
- From: Brian Hulley
- Re: Beginner's questions
- References:
- Beginner's questions
- From: Søren Hansen
- Re: Beginner's questions
- From: Brian Hulley
- Beginner's questions
- Prev by Date: dfs
- Next by Date: Re: Non dominating queens problem
- Previous by thread: Re: Beginner's questions
- Next by thread: Re: Beginner's questions
- Index(es):
Relevant Pages
|