Question: - 4. (2 points) Write a function named apply that takes a function foo and a list ist as arguments, then applies foo to Ist

 - 4. (2 points) Write a function named apply that takes

- 4. (2 points) Write a function named apply that takes a function foo and a list ist as arguments, then applies foo to Ist such that all elements in Ist are used as arguments of foo. For example, apply (+) (1,2,3,4] => 10 apply () [1,2,3,4] => 24 5. In Haskell, a binary tree can be defined as: data BTree a - Empty | Bode a (BTree a) (BTree a) a) (2 points) Define the function flatten that flattens the nodes in a given binary tree. For example, flatten(Bode 3 (Node 2 Empty Empty) Empty) -> (2,3) flatten(BNode 3 (BNode 2 Empty Empty) (Node 4 Empty Empty)) -> (2,3,4] b) (2 points) Define the function height that returns the height of a given tree For example, height(BNode 3 (BNode 2 Empty Empty) Empty) => 1 height(BNode 3 (Node 2 Empty Empty) (BNode 4 Empty Empty)) => 1 - 4. (2 points) Write a function named apply that takes a function foo and a list ist as arguments, then applies foo to Ist such that all elements in Ist are used as arguments of foo. For example, apply (+) (1,2,3,4] => 10 apply () [1,2,3,4] => 24 5. In Haskell, a binary tree can be defined as: data BTree a - Empty | Bode a (BTree a) (BTree a) a) (2 points) Define the function flatten that flattens the nodes in a given binary tree. For example, flatten(Bode 3 (Node 2 Empty Empty) Empty) -> (2,3) flatten(BNode 3 (BNode 2 Empty Empty) (Node 4 Empty Empty)) -> (2,3,4] b) (2 points) Define the function height that returns the height of a given tree For example, height(BNode 3 (BNode 2 Empty Empty) Empty) => 1 height(BNode 3 (Node 2 Empty Empty) (BNode 4 Empty Empty)) => 1

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!