Prolog predicate problems -


I'm just starting with Prologue, and I do not understand why the following does not work as I hope to do this I am trying to make a reality which returns the returns if the list is listed in L2, this is what I have written:

  emphasize (in (L1, L1 Emphasis is included (in (L1, [x | L2]): - Member (X, L1), contains (L1, L2) in emphasis (in (L1, [])  

I thought it would be equal to "L3 = x | L2 'in L1, and L2 is also in L1", which includes ( L1, L2) until all the time All have been crossed and we leave with the last option, or we search for that member who is not in L1, and this will fail the failure.

Unfortunately, It seems that does not work like this. It seems that only the value of the member (X, L1) is to be returned, so in this ([1,2,3], [1,4,5]) passes

What am I doing wrong?

Div class = "post-text" itemprop = "text">

I The question was not fully understood but I writes / writes / defined like this:

 % Any list contains an empty list (_, []). % If a list is not empty, its% first element should be element of L1,% and its tail will be rooted by L1. Includes (L1, [x | L2]): - Member (X, L1), contains (L1, L2) in it  

BTW, note that your The first rule (fact)

  contains (L1, L1)  

is a syntax error (should not be a location after the prediction number ). Also, if it is correct, then it will choose an unwanted option, so remove it.

If you want to use dependent / 1 on the preel signal, execute

 ? - assure (include (_, [])). Yes? - Claim (L1, [x | L2]): - (Member (X, L1), (L1, L2)) are included. Yes  

To end in the Knowledge Base, use Listing / 0 .

 ? - Listing: - Includes dynamic / 2 included (_, []). Includes (B, [A | C]): - Members (A, B) include (B, C) Yes  

I do not think the problem is "emphasizing the free variable "As you point out in your own answer. Instead, check your braking.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -