Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 2: Prolog Parsing Write Prolog predicates that will read a file containing positive integers, will sum all the integers found in that file, and

image text in transcribed

Project 2: Prolog Parsing Write Prolog predicates that will read a file containing positive integers, will sum all the integers found in that file, and return the sum to the environment. The following are the specifications. The main predicate the user will call shall be named fileSum/2. The first argument will be the filename, and the second argument will match with the sum of the integers in the file. The user will not call any other predicates you write. You may assume the integers in the file are positive only. You can't use the built-in predicates that Prolog has defined. You must use the logic/recursive programming style where appropriate. Do not use loops or other procedural techniques. To assist in readability, break up tasks by writing helper predicates when possible. For example, you can create a predicate named is Rigit/1, which succeeds if and only if its argument has an ASCII value of one of the digits o through 9. Comment your code briefly but thoroughly. The following is a rough rubric to help guide you on how the project will be graded: . A: Your code uses the get and/or geto predicates to handle files where the integers can be any number of digits and are separated by one or more characters that are not digits located in multiples lines of the file. The last integer read may or may not be followed by one more non- digits before the end of the file is reached. The organization, layout, and commenting of your code/functions is clear and precise in helping the reader understand all its components. Project 2: Prolog Parsing Write Prolog predicates that will read a file containing positive integers, will sum all the integers found in that file, and return the sum to the environment. The following are the specifications. The main predicate the user will call shall be named fileSum/2. The first argument will be the filename, and the second argument will match with the sum of the integers in the file. The user will not call any other predicates you write. You may assume the integers in the file are positive only. You can't use the built-in predicates that Prolog has defined. You must use the logic/recursive programming style where appropriate. Do not use loops or other procedural techniques. To assist in readability, break up tasks by writing helper predicates when possible. For example, you can create a predicate named is Rigit/1, which succeeds if and only if its argument has an ASCII value of one of the digits o through 9. Comment your code briefly but thoroughly. The following is a rough rubric to help guide you on how the project will be graded: . A: Your code uses the get and/or geto predicates to handle files where the integers can be any number of digits and are separated by one or more characters that are not digits located in multiples lines of the file. The last integer read may or may not be followed by one more non- digits before the end of the file is reached. The organization, layout, and commenting of your code/functions is clear and precise in helping the reader understand all its components

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions