Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a pangram using OCAML Here are examples of .txt files input1.txt we promptly judged antique ivory buckles for the next prize. nymphs blitz quick

Write a pangram using OCAMLimage text in transcribedimage text in transcribedHere are examples of .txt files

input1.txt

we promptly judged antique ivory buckles for the next prize. nymphs blitz quick vex dwarf jog. djs flock by when mtv ax quiz prog. big fjords vex quick waltz nymph. bawds jog, flick wartz, vex nymph.

input2.txt

mr.dumbledore is a funny name for a dog. as a volunteer sherrif's deputy i've been doing surveillance for years. back then, my life was so great that i literally wanted a second one. everything was absolutely the same, except that i could fly. congratulations on your one cousin--i have seventy, each one better than the last!

output1.txt

true true true true false

output2.txt

false false false false false

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 representative and has been formatted to look good in pdfs, 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 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 representative and has been formatted to look good in pdfs, 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

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_2

Step: 3

blur-text-image_3

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

Neo4j Data Modeling

Authors: Steve Hoberman ,David Fauth

1st Edition

1634621913, 978-1634621915

More Books

Students also viewed these Databases questions