Trying to make a Goal that is satisfied if another goal runs 10 times in Prolog -


  R1 (x, z): - backwards (x, z) R1_10 (X, Z): - R1 (X, Z),   

I have this code. The idea is that if R1 is satisfied 10 times then r1_10 will be satisfied I am new to prologue and I am not sure how to loop it exactly. I was just thinking about Brute that forced the same line 10 times, but I should be able to do things like R1_30, so that there is a lot of code for no reason.

Thank you!

Edit: This answer helps so much, but just to clarify what I was asking. Basically, I have the target R1 which makes my last / 2 plant calls which gives me only behind the list. I have two types of back / 2 predictions, one of which is not an accumulator and one. R1_10 is a goal that will ultimately show me that the person using a container is faster and better. The goal R1_10 is simply a way to run the target R1 10 times. I am pretty sure that I do not need different results, I need to be able to know that it will be successful after 10 times R1 expires. Hope it helps!

It is not clear what you mean by "10 times satisfied" do you mean that < There will be 10 solutions in the code> r1 / 2 hypothesis? An example goal would be the member (X, [1,2,3,4,5,6,7,8,9,0]), which, on the back tracking, the variable If for every one of the X list elements, then use the standard findall / 3 to calculate the list of all the targets of the target, and then the length of the list There can be a solution to calculate. For example:

  r1_10 (x, z): - search (_, r1 (x, z), solution), length (solution, 10).   

This predicate can be easily normalized using an additional logic so that the number of solutions can be crossed.

On the other hand, if you want to make N goals only once, then you can define a definition that is a goal and a counter. For example:

  call_n_times (n, target): - (1, n, _),% generated, on back tracking, all numbers in interval [1, n] once (target ), Failed call_n_times (_, _)   

This definition assumes that the goal never fails (or throws an error). This is not clear from your question, what should be the goal if target N can not be satisfied. Can the collar fail in that case? If so, you will need a different definition. For example (again assume that the goal never fails or throws an error):

  call_n_times (0, _): -! Green cut to avoid% counterfeit option-point call_n_times (n, target): - N & gt; 0, once (target), mn-1, call_n_time (m, target).   

But this definition may still be problematic. For example, if you pass a goal which is not a land, i.e. with variables in it, and by calling the target, some of its variables are instantly transformed, which will be successful in the next phase Prevents from One way to avoid this potential problem is to use the following compact definition:

  call_n_times (n, target): - forall (between (1, n, _,, target).   

forall / 2 and between / 3 are actual standard predictions forall / 2 predicate The truth is, when for each solution of the first argument, the second argument is true (thus a Generated and Test Loop applies).

We Use some more details on the nature of the goals you want to complete.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -