Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

Prolog program to define the relation translate(L1,L2) to translate a list of numbers 0-9 to a list of corresponding words i.e. 0 - zero 1 - one

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

Program to define the relation translate(L1,L2) to translate a list of numbers 0-9 to a list of corresponding words i.e. 0 - zero 1 - one

Code for Prolog program to define the relation translate(L1,L2) to translate a list of numbers 0-9 to a list of corresponding words i.e. 0 - zero 1 - one in Artificial Intelligence

domains
    x = integer
    l = integer*
    w = symbol
    wl = symbol*
    
predicates
    means(x,w)
    translate(l,wl)
    
clauses
    means(0,zero).
    means(1,one).
    means(2,two).
    means(3,three).
    means(4,four).
    means(5,five).
    means(6,six).
    means(7,seven).
    means(8,eight).
    means(9,nine).
    
    translate([],[]).
    
    translate([X|List],[What|ConvertedList]) :-
        means(X,What),
        translate(List,ConvertedList).
 
      
Output :

Goal: translate([1,2,3,4],ConvertedL)
ConvertedL=["one","two","three","four"]
1 Solution
  
Share: 



Milind Mishra
Milind Mishra author of Prolog program to define the relation translate(L1,L2) to translate a list of numbers 0-9 to a list of corresponding words i.e. 0 - zero 1 - one is from India.
 
View All Articles

Related Articles and Code:


 

Other Interesting Articles in Artificial Intelligence:


 
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!