Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The definition of listCompare is below in Haskell. listCompare :: ([Int], [Int]) -> [Bool] listCompare ([], [] ) = undefined listCompare (x : xs, y

The definition of listCompare is below in Haskell.

listCompare :: ([Int], [Int]) -> [Bool]

listCompare ([], [] ) = undefined listCompare (x : xs, y : ys) = undefined listCompare (x : xs, [] ) = undefined listCompare ([], y : ys) = undefined

test_listCompare1 = listCompare ([], []) == [] test_listCompare2 = listCompare ([1, 2, 4], [3, 2, 0]) == [True, False, False] test_listCompare3 = listCompare ([-2, -5, 0], [-6, 2, 0]) == [False, True, False] test_listCompare4 = listCompare ([5, 4, 3, 2], [2, 9]) == [False, True, False, False] test_listCompare5 = listCompare ([1, 0], [1, 1, 1, 1]) == [False, True, False, False]

test_listCompare = test_listCompare1 && test_listCompare2 && test_listCompare3 && test_listCompare4 && test_listCompare5

image text in transcribed

3a. Fill in the definition of listCompare, which takes two lists of Ints, and should return a list of Bools such that: - if the kth element of the first list is equal to the kth element of the second list, the kth element of the result should be True (because the elements are the same); - if the kth element of the first list is not equal to the kth element of the second list, the kth element of the result should be False (because the elements are different); - if the first and second lists are of different lengths, the result should be "padded" with False, so that the result list is as long as the longer input. Examples: (resulting list is length 4 ) 3b. The function listCompare only works with integer lists. Fill in the definition of genCompare, which takes two arguments: 1. a comparison function cmp, of type a a Bool, which takes two a's and returns True if they should be considered equal, and False if they should be considered non-equal; 2. two lists, where each list's elements have type a

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

Step: 3

blur-text-image

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

Describe current business topics and their impact on HRM.

Answered: 1 week ago