CS 320 Assignment 1 Pangram solution

$24.99

Category:

Description

5/5 - (2 votes)

Write a program with OCaml.
Your program will consist of a function that accepts two strings. Each string is the name of a file.
The first is the name of an input file and the second is the name of an output file. Name the function
pangram. (Note that your program can also make use of other helper functions. Just make sure the
function pangram takes as argument a pair of string describing the input file and output file.)
A pangram is a sentence that contains all the letters of the English alphabet at least once. For example,
the following sentence:
the quick brown fox jumps over the lazy dog
is a pangram. The program you are to write must read in an input file (input.txt, a plain text file
which contains some sentences, one on each line), line by line and check if the line read is a pangram
or not. If the sentence read is a pangram, it writes true to the output file. If it is not, it writes false
to the output file.
For example, if input.txt contains:
we promptly judged antique ivory buckles for the next prize.
how quickly daft jumping zebras vex.
pottery is an art.
crazy fredrick bought many very exquisite opal jewels.
mr. dumbledore is a funny name for a dog.
Then your program must output the following to the output.txt:
true
true
false
true
false
NOTE: The text that you write to the output file (output.txt) is case sensitive – please use only
lower-case letters when you write to the output file. Moreover, the example provided here is only
1
representative and has been formatted to look good in pdf’s, take a look at the sample input and
output files for a precise formatting of what your program will actually read in and should output.
You can also assume that the sentences in input.txt will contain only lower-case letters.
Please use the sample test cases provided to test your code locally and submit your solution to
Gradescope for grading. For the purpose of this assignment, you do not need to perform any specific
error checking on the files. Your program can assume that the files exist (for the input file) or can be
created or overwritten (for the output file).
Your code should be written in pangram.ml. The pangram function you need to create takes as input
a pair of two strings as arguments: the first for the name of input file and second for the name of
output file. So, the function must adhere to the following type signature: string * string -> unit.
OCaml Resources
To process string, you may find following function from Module String is helpful:
• contains : string -> char -> bool
String.contains s c tests if character c appears in the string s
For further detail, please go to String module in the OCaml document:
https://caml.inria.fr/pub/docs/manual-ocaml/libref/String.html
Submission Instructions
In order to make sure the Gradescope autograder can successfully run your code, your submitted file
name must be pangram.ml.
Late submissions will not be accepted. The deadline for submission is Fri. 11:59pm 09/27/2019.
You can use Gradescope to confirm your program adheres to the specification outlined. Only your
last submission will be graded for you final grade. This means you can submit as many times as you
want. If you have any question please post it well before the due date on piazza.
2