4 FUNCTIONAL PROGRAMMING WITH HASKELL Write HASKELL definitions for the following functions:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please I need correct and working answers only, don't copy paste from old chegg questions. Don't waste your and my times please, thanks.

 

Assignment 4 FUNCTIONAL PROGRAMMING WITH HASKELL

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 f lst: returns the list consisting of members of lst 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 lst: lst 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 lst: returns a list, obtained from lst, 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 lst 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 lst: 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’), (“math163”,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 list1. 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_i 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_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].

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY