Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to add an element in a head position in given list

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

Prolog program to add an element in a head position in given list.

Code for Prolog program to add an element in a head position in given list in Artificial Intelligence

domains

    list=symbol*

    
predicates

    add(symbol,list,list)

    
clauses

    add(X,L2,[X|L2]).

        
OUT PUT
=======

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

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

1 Solution
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to add an element in a head position in 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!