Hello, I need the HASKELL code in addition to the output testing please.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Hello, I need the HASKELL code in addition to the output testing please.

Post by answerhappygod »

Hello, I need the HASKELL code in addition to the output testing
please.
Hello I Need The Haskell Code In Addition To The Output Testing Please 1
Hello I Need The Haskell Code In Addition To The Output Testing Please 1 (201.99 KiB) Viewed 25 times
Hello I Need The Haskell Code In Addition To The Output Testing Please 2
Hello I Need The Haskell Code In Addition To The Output Testing Please 2 (96.57 KiB) Viewed 25 times
Write HASKELL definitions for the following functions: 1. order a b c: returns a ternary tuple (tuple with 3 parts) of a, b and c such that the first element is less-or-equal the second, and the second is less-or-equal the third element. For example, order 4 2 3 should return (2,3,4). 2. fltr flst: returns the list consisting of members of 1st that make the function f return True when applied to it. For example, fltr even [1,2,2,5,8,4] should return [2,2,8,4]. f can be any function that takes one parameter of the same type as list elements. 3. compute 1st: 1st is a list of pairs of numbers, and the anwser is a list formed as follows - if the first component is smaller than the second one, then their multiplication is in the resut. Otherwise, their addition is in the result. 1. Example 1: compute [(2,3), (8,4),(4,6)] should return [6,12,24]. 2. Example 2: compute [(8,7),(1,1),(4,5),(2,5)] should return [15,2,20,10]. 4. eliminate 1st: returns a list, obtained from 1st, such that a is in the result only if it is smaller than the next element that follows it in lst. For example, eliminate [4,3,6,5,7,9,6] should return [3,5,7]. Note that the last element of 1st will never be in the result, because there is no other element after it. (hint: use the pattern (x:(y:t)) to access the first and second elements in front of the list. Or you can use head and tail functions.) 5. gpa 1st: computes the gpa in a given semester, given a list of (course,credit,grade) tuples. An 'A' counts as 4, 'B' counts as 3, 'C' counts as 2 and 'D' counts as 1. Example: gpa [("cmse318", 4, 'A'), (“math 163",3, 'C')] should return 3.14 ((4*4+2*3)/7). 6. howmany elem a_list: returns how many elems are in a_list. For example, howmany 'b' ['a', 'b', 'c', 'b', 's'] should return 2. 7. pair_lists list1 list2: returns a list of pairs, where the first component of a pair in position i is in position i of list2 and the second component of a pair in position i is in position i of listl. For example, pair_lists [3,4,5] [10,20,30] should return [(10,3),(20,4),(30,5)]. You can assume that the two lists have the same size.

8. classify_g n: returns a letter grade based upon a numeric grade, according to the following schema:n>=90 'A', 80<=n<=89 'B', 70<=n<79 'C', otherwise 'D'. For example, classify_g 87 should return 'B'. Define classify_g with guards to implement this function. 9. classify_in: returns a letter grade based upon a numeric grade, according to the following schema: n=90 'A', 80<=n<-89 'B', 70<=n<79 'C', otherwise 'D'. For example, classify_i 87 should return 'B'. Define classify_i with the if expression to implement this function. 10. first_odds n: returns a list of the first n odd numbers. For example, first_odds 5 should return [1,3,5,7,9]. What to submit through Moodle (and also through Teams): • A report containing your code and sample runs. Call each function with two different sets of parameters. • File containing your Haskell code
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply