Question: Write the codes in HASKELL. 1. Recall that the function combinations takes a list of elements of typeclass Ord and an integer k as its

Write the codes in HASKELL.

1. Recall that the function combinations takes a list of elements of typeclass Ord and an integer k as its arguments and returns a list of Write the codes in HASKELL. 1. Recall that the function combinations takeslength k lists representing all possible subsets of size k. The function splits is similar, except that, given a list of elements of length n, it returns a list of a list of elements of typeclass Ord and an integer k as pairs of lists. The first component of the pair represents a combination of length k. The second component represents the complementary combination of length n?k. Two combinations are complementary when their union is equal to the original list. Write splits.

For example:

*Main> :t splits splits :: (Ord a) => [a] -> [([a], [a])]

*Main> splits "abc"

[("c","ab"),("b","ac"),("bc","a"),("a","bc"),("ac","b"),("ab","c")]

2. The function argmin takes a function f and a list xs as arguments and returns the element of the list x such that f applied to x has minimum value. Write argmin.

For example:

*Main> :t argmin

argmin :: (Ord a) => (t -> a) -> [t] -> t

*Main> argmin length ["ABC","EF","GHIJ","K"]

"K"

Thank you.

n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!