Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. everlonggg

    'fail' predicate confusion

    Gotcha! And in the way it works in recursive list cases... let's make up an example. f([], 0). f([H|T], X):- f(T, Y), g(H,Z), X is Y+Z. g(a, 1). g(X, 0). inputting f([a,b,a],X), write(X), fail. to this will give you something like... 2110. It will get the first 2, fail. go back and instead...
  2. everlonggg

    'fail' predicate confusion

    Sorry, 14. That was a mistake on my behalf. So what you're saying is that the fail predicate doesn't make it start the whole second rule over again, but only checks for a new b(Y)?
  3. everlonggg

    'fail' predicate confusion

    the second rule is executed at the last point of choice : fact with b ==> 4 fail" This step does not make logical sense to me. Why would this not print 2, 4?
  4. everlonggg

    'fail' predicate confusion

    The fail predicate seems a bit unpredictable under certain cases to me. Take the following example. Code: a(1). a(2). b(3). b(4). go:- a(X), write(X). go:- a(X), write(X), b(Y), write(Y). Query this with ?- go, fail. The result is 12134234. How does this make sense? Can somebody explain the...

Part and Inventory Search

Back
Top