Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
- 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

5. Develop the succession planning review.

Answered: 1 week ago