Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to read list of strings and numbers and copy in database having having string length equal to number

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

Complete prolog program to read a list of strings. Then read a no. All the strings having the length as the same number are to be copied to the database.

Code for ProLog Program to read list of strings and numbers and copy in database having having string length equal to number in Artificial Intelligence

%trace
domains
    file = input
predicates
    start
    readline(integer)
    comp(integer,integer)
goal
    clearwindow,
    start.
clauses
    start:-
        openread(input,"Q3I.TXT"),
                
        write("\nEnter the no::"),
        readint(No),
        
        readdevice(input),
        readline(No).
        
    readline(No):-
        not(eof(input)),
        readln(Line),
        str_len(Line,Len),
        nl,write(Line,"  ",Len),
        comp(No,Len),
        readline(No).
    comp(No,Len):-
        No=Len,
        write(Len).
    comp(_,_).
  
Share: 



Milind Mishra
Milind Mishra author of ProLog Program to read list of strings and numbers and copy in database having having string length equal to number is from India.
 
View All Articles

Related Articles and Code:


 
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!