1. Engineering
  2. Computer Science
  3. module csc207a1testdata where tests 1 7182 370507213692...

Question: module csc207a1testdata where tests 1 7182 370507213692...

Question details

Define a Haskell function named sumOfSquareAndCube that, given an input value x, compute the sum of its square and cube. That is sumofSquareAndCube(x) x2+ Examples: sumof Square Andoube 2う12 sumof SquareAndcube 10 1100 The file csc207a1.hs contains the prototype for the function (in which it always returns a probably incorrect value value of 0). You should change the implementation so that it works as described above. Be careful not to change the first line. It is required to make the tester work. You can test your fundtion using the data shown above. Once you feel comfortable that your function i working correctly, you can use the tester to do more extensive tests. Just load the tester into ghei (or Winghcá) and ask it to show the results. The following shows what you get when running the tester against the invalid solution: GHCi, version 8-4.2: http://www.haskell.org/ghc/ :? for help Prelude> :load CSC207a1 Tester.hs 1 of 3) Compi1ing CSC207a1 [2 of 3) Compiling CSC207a1TestData CSC207alTestData.hs, interpreted) 13 of 3) Compiling CSC207a1Tester CSC207alTester.hs, interpreted) Ok, modules 1oaded: CSC207al Tester, csC207al, CSC207a 1TestData CSC207alTester> results CSC207a1.hs, interpreted ) ,27, 28,29,30, 31,32,33, 34, 5,46,47, 48,49,50, 51,5 The result contains a tuple of three values. The first (highlighted in green) is a floating-point value representing your score (on a scale of 20 points). The second (high lighted in blue) is a list of all test cases that you passed. The third (highlighted in pink) is a list of all test cases that you failed. You can look up the test cases in the csc207a1TestData.hafile. This file defines a single list named tests and it contains a list of tests (in the form of tuples. Each test (tuple) has three elements: .An integer representing the test case number .An integer value representing the input parameter An integer value representing the expected output from calling sumof SquareAndcube with the given input parameter The following shows the first few lines in csc207a1TestData hs: module CSC2 07 a 1 TestData wher tests-1,7182, 370507213 692) 2, 2481 15277606002) 3, 3610,47058913100) 4, 6266, 246059691852) S, 8017 S153 35213202)

CSC207a1Tester.hs 88 く 〉 、csc207a1 Tester.hs 〉 No Selection 1 module csc207a1Tester where 3 import CSC207a1 4 import CSC207a1TestData 6 testOne input value -valuesumofSquareAndCube input 7 testAll tests = [(i, testone input value) (1, input, value) <-tests] 8 result-testAll tests 9 score = sum [1 (i, x) <-result, x == True] * 0.2 10 passed = [i I (i, x) <-result, x == True] 11 failed = [i | (i, x) <-result, x = False] 12 results= (score, passed, failed) 13​​​​​​​

module CSC207a1TestData where

tests = [( 1, 7182, 370507213692),

   ( 2, 2481, 15277606002),

   ( 3, 3610, 47058913100),

   ( 4, 6266, 246059691852),

   ( 5, 8017, 515335213202),

   ( 6, 7107, 359021163492),

   ( 7, 9491, 855030636852),

   ( 8, 8216, 554669324352),

   ( 9, 2371, 13334532452),

   ( 10, 6919, 331278122120),

   ( 11, 5175, 138616515000),

   ( 12, 4701, 103911383502),

   ( 13, 6914, 330560483340),

   ( 14, 9018, 733464078156),

   ( 15, 7494, 420919469820),

   ( 16, 7218, 376106463756),

   ( 17, 1154, 1538131980),

   ( 18, 1359, 2511758160),

   ( 19, 2531, 16219893252),

   ( 20, 3246, 34212067452),

   ( 21, 5725, 187673228750),

   ( 22, 4374, 83701957500),

   ( 23, 1738, 5252899916),

   ( 24, 7413, 407418346566),

   ( 25, 7212, 375169365072),

   ( 26, 5444, 161374205520),

   ( 27, 2668, 18998539856),

   ( 28, 6774, 310884939900),

   ( 29, 4081, 67983918002),

   ( 30, 6964, 337783666640),

   ( 31, 5315, 150172880100),

   ( 32, 9024, 734928998400),

   ( 33, 9953, 986065228386),

   ( 34, 2501, 15650012502),

   ( 35, 5368, 154710011456),

   ( 36, 9626, 892036626252),

   ( 37, 8127, 536839192512),

   ( 38, 1962, 7556458572),

   ( 39, 5073, 130581059346),

   ( 40, 8175, 546407190000),

   ( 41, 5364, 154364441040),

   ( 42, 3392, 39038717952),

   ( 43, 2184, 10422135360),

   ( 44, 9897, 969515127882),

   ( 45, 5419, 159161340620),

   ( 46, 1179, 1640248380),

   ( 47, 4304, 79747610880),

   ( 48, 3983, 63203327376),

   ( 49, 3504, 43034446080),

   ( 50, 7891, 491418116852),

   ( 51, 3643, 48361160156),

   ( 52, 6318, 252236306556),

   ( 53, 6922, 331709203532),

   ( 54, 1519, 3507188720),

   ( 55, 7720, 460159246400),

   ( 56, 1421, 2871360702),

   ( 57, 3650, 48640447500),

   ( 58, 6021, 218312199702),

   ( 59, 5157, 137175199542),

   ( 60, 8755, 671147618900),

   ( 61, 6098, 226794998796),

   ( 62, 8654, 648187801980),

   ( 63, 3135, 30821313600),

   ( 64, 3945, 61411696650),

   ( 65, 7443, 412384565556),

   ( 66, 4031, 65515810752),

   ( 67, 9947, 984283063932),

   ( 68, 7791, 472971914352),

   ( 69, 1568, 3857581056),

   ( 70, 5305, 149326890650),

   ( 71, 2387, 13606272372),

   ( 72, 8531, 620941563252),

   ( 73, 2594, 17461329420),

   ( 74, 2726, 20264544252),

   ( 75, 3803, 55016525436),

   ( 76, 9071, 746471747952),

   ( 77, 9436, 840252511952),

   ( 78, 8778, 676450780236),

   ( 79, 2239, 11229391040),

   ( 80, 4500, 91145250000),

   ( 81, 5124, 134558802000),

   ( 82, 9888, 966872687616),

   ( 83, 6977, 339678775362),

   ( 84, 2265, 11625089850),

   ( 85, 1636, 4381423952),

   ( 86, 8356, 583508604752),

   ( 87, 1098, 1324958796),

   ( 88, 8919, 709573164120),

   ( 89, 4607, 97802260992),

   ( 90, 6823, 317679917096),

   ( 91, 3568, 45435597056),

   ( 92, 8445, 602352039150),

   ( 93, 9059, 743513257860),

   ( 94, 2370, 13317669900),

   ( 95, 6640, 292799033600),

   ( 96, 6091, 226014911852),

   ( 97, 1412, 2817160272),

   ( 98, 3543, 44487296856),

   ( 99, 1286, 2128435452),

   (100, 2989, 26713021790)]

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution