Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 function pangram takes as arguments the input file and output file that are specified in the program A pangram is a sentence that contains all the letters of the English alphabet at least once. For example, 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.trt - a plain text file which contains 5 sentences), 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 iumping zebras vex pottery is an art crazy fredrick bought many very exquisite opal jewels mr. dumbledore is a funny name for a do Then your program must output the following to the output.trt. true true true Talse NOTE: Text that you write to the output file (output.trt) is case sensitive - please use all lower case 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 assume that input.trt contains all the letters are in lower case. Please use the sample test cases provided to test your code locally and submit your solution to Autolab for grading. For the purpose of this assignment, you do not need to do 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) 1 let pangram (inFile : string) (outFile: string) : unit 2 let ic open_in inFile in let oc open_out outFile in let rec loop_read acc- 4 6 try let - input-line ic in loop-read (1: :acc) 9 10 with | End_of_file -> List.rev acc in 12 let file-write bool-val- Printf.fprintf oc "%b " boo-val in 14 15 let ls_str-loop_read [ in );; 16 17 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 function pangram takes as arguments the input file and output file that are specified in the program A pangram is a sentence that contains all the letters of the English alphabet at least once. For example, 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.trt - a plain text file which contains 5 sentences), 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 iumping zebras vex pottery is an art crazy fredrick bought many very exquisite opal jewels mr. dumbledore is a funny name for a do Then your program must output the following to the output.trt. true true true Talse NOTE: Text that you write to the output file (output.trt) is case sensitive - please use all lower case 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 assume that input.trt contains all the letters are in lower case. Please use the sample test cases provided to test your code locally and submit your solution to Autolab for grading. For the purpose of this assignment, you do not need to do 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) 1 let pangram (inFile : string) (outFile: string) : unit 2 let ic open_in inFile in let oc open_out outFile in let rec loop_read acc- 4 6 try let - input-line ic in loop-read (1: :acc) 9 10 with | End_of_file -> List.rev acc in 12 let file-write bool-val- Printf.fprintf oc "%b " boo-val in 14 15 let ls_str-loop_read [ in );; 16 17
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started