Menu

(Solved) : 4 2 Points Consider Following Claim Haskell Function Higher Order Type One Arrow Correct G Q44089372 . . .

Haskell Programming – Code

Do it in Haskell GHCI

4. (2 points) Consider the following claim: “A Haskell function is higher order if and only if its type has more than one arr

4. (2 points) Consider the following claim: “A Haskell function is higher order if and only if its type has more than one arrow.” Is this correct? Give a brief argument. Currying/Uncurrying 5. (4 = 2 * 2 points) Let f :: (a -> a -> a) -> a -> a -> a. Rewrite f * (2 3) so that it has no syntax errors and yields 6 if f h x y = h x y a. Write the definition of a function g :: ( (a, a) -> a, (a, a))-> a so that g is an uncurried b. version of f. Calling your function on *, 2, and 3 should yield 6. Map and Filter (4 = 2 * 2 points) Let f1 = filter ( x -> x > 0) and f2 = filter (x-> x < 10), and let 6. nbrFilter g x = length (filter g x). Rewrite f1 (f2[-5..15]) so that uses function composition to apply just one function to the list. a. b. Rewrite the nbrFilter function definition to have the form nbrFilter g = function composition involving length and filter… and leaving out x. Show transcribed image text 4. (2 points) Consider the following claim: “A Haskell function is higher order if and only if its type has more than one arrow.” Is this correct? Give a brief argument. Currying/Uncurrying 5. (4 = 2 * 2 points) Let f :: (a -> a -> a) -> a -> a -> a. Rewrite f * (2 3) so that it has no syntax errors and yields 6 if f h x y = h x y a. Write the definition of a function g :: ( (a, a) -> a, (a, a))-> a so that g is an uncurried b. version of f. Calling your function on *, 2, and 3 should yield 6. Map and Filter (4 = 2 * 2 points) Let f1 = filter ( x -> x > 0) and f2 = filter (x-> x

Expert Answer


Answer to 4. (2 points) Consider the following claim: “A Haskell function is higher order if and only if its type has more than …

OR