Question: Write the following ML functions using map, foldr or foldl higher - order functions. On top of your code Include 3 line comment with your

Write the following ML functions using map, foldr or foldl higher-order functions. On top of your code Include 3line comment with your name, purpose and date. Precede each function by a one-line comment including exercise number. Save your code as chapter9.txt and submit it by canvas.
1.(6p) Function multpairs of type: (int * int) list \(\rightarrow \) int list that takes a list of pairs of integers and returns the list of products of pairs. For example: multpairs [(1,3),(3,7)] should return [3,21].
2.(6p) function max of type int list \(\rightarrow \) int that returns the largest element of a given list of integers. Your function need not behave well on empty list. For example: max [1,2,7,\(\sim 9]\) should return 7.
3.(6p) Function odds of type: int list \(\rightarrow \) int list so that odds \( L \) returns the list of all odd numbers in \( L \) in the original order. For example: odds \([1,5,2,4,7,0,\sim 2]\) should return \([1,5,7]\).
4.(6p) Function cubes of type int list \(\rightarrow \) int list that returns the list of cubes of the numbers in the given list For example: cubes \([2,1,\sim 3,4]\) should return \([8,1,\sim 27,64]\).
5.(6p) Function product of type int list \(\rightarrow \) int that returns the product of a list of integers. Your function should return 1 if the list is empty. For example: product \([1,\sim 2,7,\sim 4]\) should return 56.
Write the following ML functions using map, foldr

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!