Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

PROLOG PROGRAM TO DETERMINE WHETHER A ELEMENT IS A MEMBER OF LIST

Posted By: Milind Mishra     Category: Artificial Intelligence     Views: 4699

PROLOG PROGRAM TO DETERMINE WHETHER A ELEMENT IS A MEMBER OF LIST.

Code for PROLOG PROGRAM TO DETERMINE WHETHER A ELEMENT IS A MEMBER OF LIST in Artificial Intelligence

trace
domains
    namelist = symbol*
     N = symbol
predicates
    member(symbol,namelist)
    delete(symbol,namelist,namelist)
clauses
    member(X,List):-
        delete(X,List,_). 
    delete(X,[X|Tail],Tail). 
        
    delete(X,[Y|Tail1],[Y|Tail2]):-
        delete(X,Tail1,Tail2).

                    
Output

    Goal: member(x,[a,b,x,z,
    y])
    Yes
    
    
Goal: member(t,[a,b,x,z,
y])
No
    
  
Share: 



Milind Mishra
Milind Mishra author of PROLOG PROGRAM TO DETERMINE WHETHER A ELEMENT IS A MEMBER OF LIST is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!