Question: --THIS PROGRAM IS IN HASKELL, MUST BE CODED IN HASKELL-- --this is the main given to us-- module Main where import MakeSquares import System.Environment import

--THIS PROGRAM IS IN HASKELL, MUST BE CODED IN HASKELL--
--this is the main given to us--
module Main where import MakeSquares import System.Environment import System.IO
--Program to divide a rectangle into squares. --This module handles all I/O and calls solve in module MakeSquares --to actually change an input String from a file into a list of --Int values representing the squares.
--makeOutput concatenates the input line and output list into --a labelled, readable String for output
makeOutput inputNums outputList = (inputPart inputNums) ++ " " ++ (outputPart outputList)
--inputPart is a helper function for makeOutput which makes input --line from file readable
inputPart nums = "length: " ++ (head numList) ++ " width: " ++ (last numList) ++ " " where numList = words nums --outputPart is a helper function for makeOutput which turns a list --of Int into a readable String for output
outputPart outList = "Sides of Squares: " ++ (unwords $ map show outList)
--processInput is a recursive function. Each call reads one line of input, --calls solve to do the processing, calls makeOutput to make the results --readable, and prints the results of processing one line to a file
processInput inFileHandle outFileHandle = do eof
main = do [inFile, outFile] Overview For this assignment youw be determining how to divide a rectangle into squares. At each step of the process, you will be creating the largest possible square out of the remaining rectangle. Your processing will stop when the last rectangle you wil be dividing is already a square Specifics Your program will work on a file of integer values, two integers per line. Each line will represent exactly one rectangle. Each rectangle (line of input) will be processed to determine how to divide it into squares. The portion of the program which does input and output has already been written for you. This portion of the code is located in module Main, which is stored in file Main.hs. You will write module MakeSquares which you will store in file MakeSquares.hs. MakeSquares will have a function solve of type solve String - [Int] in which String is a line from the input file, and Int is a list of squares from largest down to smallest each of which is represented by a single integer, the value of a side of a square. These squares are the result of dividing the given rectangle into squares. Note that the String argument to solve will contain two integer values in String format, separated by white space. Note that you will be writing solve, and as part of solve you will be calling other functions, some of which you will write yourself. Sample input fil
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
