In an imperative language with lambda expressions (e.g., C#, Ruby, C++, or Java), write the following higher-level

Question:

In an imperative language with lambda expressions (e.g., C#, Ruby, C++, or Java), write the following higher-level functions. (A higher-level function, as we shall see in Chapter 11, takes other functions as argument and/or returns a function as a result.)

compose(g, f)—returns a function h such that h(x) == g(f(x)).

map(f, L)—given a function f and a list L returns a list M such that the ith element of M is f(e), where e is the ith element of L.

filter(L, P)—given a list L and a predicate (Boolean-returning function) P, returns a list containing all and only those elements of L for which P is true.

Ideally, your code should work for any argument or list element type.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: