Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Sup Standard ML Further Reading 85 Exercise 12 Write a function pow of type real int -> real that raises a real number to
Sup Standard ML Further Reading 85 Exercise 12 Write a function pow of type real int -> real that raises a real number to an integer power. Your function need not behave well if the integer power is negative. Exercise 13 Write a function max of type int list > int that returns the largest element of a list of integers. Your function need not behave well if the list is empty. Hint: Write a helper function maxhelper that takes as a second parameter the largest element seen so far. Then you can complete the exercise by defining fun max x = maxhelper (t1 x, hd x); Exercise 14 Write a function is Prime of type int -> bool that returns true if and only if its integer parameter is a prime number. Your function need not behave well if the parameter is negative. Exercise 15 Write a function select of this type: ce? 'a list ('a- -> bool) -> 'a list that takes a list and a function f as 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 ([1,2,3,4,5,6,7,8,9,10]. 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started