Write a Prolog program to determine whether a element in a member of list in Artificial Intelligence.


% PROLOG PROGRAM TO DETERMINE WHETHER A ELEMENT IS A MEMBER OF LIST 
% Alamgir Hossain, CSE, JUST

list=integer*

findnum(integer,list).

findnum(X,[]):-
    write('The number is Not Found in the list.').
    
findnum(X,[X|Tail]):-
        write('The number is Found in the list.').            

findnum(X,[Y|Tail]):-
        findnum(X,Tail).
        
        
% Input : findnum(3,[1,2,3,4,5]).
% Output : The number is Found in the list. 
 
Input : findnum(3,[1,2,3,4,5,6,7,8,10,11,12]).
Output : The number is Found in the list.

No comments:

Post a Comment