Logo 
Search:

Artificial Intelligence Articles

Submit Article
Home » Articles » Artificial Intelligence » ProLogRSS Feeds

ProLog Program to read a file and create a list of all words of it

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

Program to read a file and create a list of all words of it...

Code for ProLog Program to read a file and create a list of all words of it in Artificial Intelligence

%trace
domains
    file = input;output
predicates
    repeat
    start
    readfile
    find(integer)
clauses
    repeat.
        repeat:-
            repeat.
    start:-
        openread(input,"readfile.txt"),
        readdevice(input),
        readfile,
        filepos(input,0,0),
        readdevice(keyboard),
        write("Enter the no::"),
        readint(No),
        readdevice(input),
        find(No).
    readfile:-
        not(eof(input)),
        readln(Line),
        str_len(Line,Len),
        write(Line,"  ",Len),
        readfile.
    readfile.
    find(No):-
        repeat,
        not(eof(input)),
        readln(Line),
        str_len(Line,Len),
        No=Len,
        openwrite(output,"writefile.txt"),
        writedevice(output),
        write(Line),
        closefile(output),
        write("File successfully written").
  
Share: 



Milind Mishra
Milind Mishra author of ProLog Program to read a file and create a list of all words of it 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!