Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to delete an element from a given list

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

Prolog program to delete an element from a given list.

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

domains

    list=symbol*

    
predicates

    del(symbol,list,list)

    
clauses

    del(X,[X|Tail],Tail).
    
    del(X,[Y|Tail],[Y|Tail1]):-
        del(X,Tail,Tail1).
        

OUT PUT
=======

Goal: del(c,[a,b,c,d,e],NewList)

NewList=["a","b","d","e"]

1 Solution

--------------------------------

Goal: del(a,[b,a,c,a],L)

L=["b","c","a"]

L=["b","a","c"]

2 Solutions
  
Share: 


Didn't find what you were looking for? Find more on Prolog program to delete an element from a given list Or get search suggestion and latest updates.

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