F
F
fantom00052016-04-19 05:39:35
Prolog
fantom0005, 2016-04-19 05:39:35

At me the recursion in a predicate does not come to the end. What to do?

Guys, hello! I need to do a fact-based search in prologue for several parameters that change dynamically. I understand that you need to make a list with id facts and then remove unnecessary elements from this list or create a new list with the necessary elements. The fact I have is a snowboard, it eats id, Brand and many different parameters. I wrote a predicate that creates a new LIST by brand, but this predicate does not exit the recursion. Help!!!

class predicates
    member : (integer, integer*) nondeterm (i,i).
clauses
    member(X,[Y|_]):-
        X=Y,!.
    member(X,[_|Y]):-
        member(X,Y).

class predicates
    createListId : (integer*, integer*) nondeterm (i,o).
clauses
    createListId(List, Out) :-
       snowboard(Id,_,_,_,_,_,_),
       not(member(Id,List)),!,
       createListId([Id|List],Out).
       createListId(A,A).

class predicates
    cutBrand : (string, integer*, integer*) nondeterm anyflow.
clauses
    cutBrand(_,[], _).
    cutBrand(Brand, [H|T], NewList):-
        snowboard(H, B,_,_,_,_,_),
        Brand=B,!,
        cutBrand(Brand,T,[H|NewList]).
    cutBrand(Brand, [H|T], NewList):-
        cutBrand(Brand,T,NewList).
    cutBrand(_,A,A).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question