a) Write a function that collects integers from the user until a 0 is encountere
ID: 3550826 • Letter: A
Question
a) Write a function that collects integers from the user until a 0 is encountered and returns them in a list in the order they were input (ML only).
B) Use the functions you wrote for exercises (b) and (c) to write a program to input a 0-ended list of integers, print the list in the order entered, and print the maximum and minimum of the list. For this exercise, use only ML.
C)Write Quicksort for a list of integers (ML only).
D) A Pythagorean triple is a tuple of integers (x, y, z) such that x * x + y * y = z * z. Write a function with a parameter n to print all Pythagorean triples such that 1 ? x ? y ? z ? n.
E) Write a higher-order function twice that takes as a parameter a function of one argument and returns a function that represents the application of that function to its argument twice. Given the usual definition of the square function, what function is (twice (twice square))?
Explanation / Answer
This function utilizes the minmax and the zerodelim functions from exercises (b) and (c). In this implementation, function composition is used such that (g ? f) (x) or in this case (minmax ? zerodelim) (x).
c)
According to the NIST definition of quicksort
1 2(define findminmax(lambda() (minmax (zerodelim '())))) Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.