Question: Write the SML functions that will read a file containing positive integers, will sum all the integers found in that file, and return the sum

Write the SML functions 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 function the user will call shall be named fileSum, which should have the type string -> int. It will take the users filename as a string and return the sum of the integers in the file. The user will not call any other functions you write.

You may assume the integers in the file are positive only.

You can open the TextIO structure in your code. You must get permission if there are other structures or library functions you intend to use.

You must use the functional/recursive programming style where appropriate. Do not use loops or other procedural techniques.

To assist in readability, break up tasks by writing helper functions when possible. For example, you can create a function named isDigit: char -> bool which receives characters and returns true if it is a character between 0 and 9 and returns false otherwise.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!