Question: please wok in haskell We can represent a two dimensional (sparse) array of characters in Haskell as a list of pairs of the form ((r.c),char)
We can represent a two dimensional (sparse) array of characters in Haskell as a list of pairs of the form ((r.c),char) where r and c are integers representing the row and column where char appears. If a row-column pair does not appear, then we assume that the entry is a space character, . For simplicity, we assume that the entries in the list are in row-major order. This means that each row is listed from left to right, one row after the other. Thus the 3 by 3 grid below: Ixl lol I Ixo 1 Ix would be represented by the list: [(0,0), 'x'), ((0,2), 'o'),((1,1), 'x'), ((1,2),'o'), ((2,2), 'x')] The horizontal and vertical lines are there to make the grid more readable and are not in the list.. You will notice that all the elements in row 0 are listed from left to right, then the elements of row 1, etc. (a) Please write a function lessThan (i,j) (m,n) that determines if index (1,3) comes strictly before index (m,n) in row-major order as described above. Thus lessThan (1,4) (2,2) should return True. It should have type lessThan :: (Ord a, Ord ab) => (a, al) -> (a, al) -> Bool Note that == works as expected on pairs of integers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
