Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to delete an element from a list using concatenate

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

Prolog program to delete an element from a list using concatenate.

Code for Prolog program to delete an element from a list using concatenate in Artificial Intelligence

domains
    x = integer
    l = integer*
    
predicates
    delete(x,l,l)
    concatenate(l,l,l)
    
clauses
    concatenate([],List,List).
    
    concatenate([X|List1],List2,[X|List3]) :-
        concatenate(List1,List2,List3).
        
    delete(Element,List,DelList) :-
        concatenate(List1,[Element|List2],List),
        concatenate(List1,List2,DelList),
        write("The list after deleting " , Element , " is "),
        nl.

        
Output :

Goal: delete(3,[3,1,6,5,4],List)

The list after deleting 3 is
List=[1,6,5,4]
1 Solution
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to delete an element from a list using concatenate 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!