jeudi 30 mars 2017

Prolog , return a value from recursion after if statement

I would like liar_detector to return Solution = Try , where Try is a list , if test_liars returns True , else continue searching , when asked from prolog.

liar_detector(Friends,Try,Max,Solution) :-
    Try == Max -> liar_detector(Friends,Try,0,Solution) ;
    (
        add2(Try,[1,0],NewTry),
        liar_detector(Friends,NewTry,Max,Solution),
        count(1,Try,N),
        test_liars(N,Friends,Try,Flag),
        ( Flag = 'True' -> Solution = Try)
    ).

Aucun commentaire:

Enregistrer un commentaire