Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The question is refers to SML Exercise 15 Write a function select of this type: a list * ('a -bool) -'a list that takes a

image text in transcribed

The question is refers to SML

Exercise 15 Write a function select of this type: a list * ('a -bool) -'a list that takes a list and a function fas parameters. Your function should apply fto each element of the list and should return a new list containing only those elements of the original list for which freturned true. (The elements of the new list may be given in any order.) For example, evaluating select (01,2,3,4,5,6,7,8,9,101, isPrime) should result in a list like [7,5,3,2]. This is an example of a higher-order function, since it takes another function as a parameter. We will see much more about higher-order functions in Chapter 9. Exercise 15 Write a function select of this type: a list * ('a -bool) -'a list that takes a list and a function fas parameters. Your function should apply fto each element of the list and should return a new list containing only those elements of the original list for which freturned true. (The elements of the new list may be given in any order.) For example, evaluating select (01,2,3,4,5,6,7,8,9,101, isPrime) should result in a list like [7,5,3,2]. This is an example of a higher-order function, since it takes another function as a parameter. We will see much more about higher-order functions in Chapter 9

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

More Books

Students also viewed these Databases questions