Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 use the built-in predicates we covered in class. You must get permission if there are other built-in or library predicates you intend to use.

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 isDigit/1, which succeeds if and only if its argument has an ASCII value of one of the digits 0 through 9.

Comment your code briefly but thoroughly.

You may work with a partner. If you do, include in the comments a brief statement on how the work was divided and/or who was responsible for which pieces of code.

If you use ideas/code from other sources, cite them in the comments.

Be prepared to set an office appointment for a presentation/demonstration/defense of your project, which can be a part of your grade.

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions