Question: Write the following ML functions: Write a function that takes two lists as parameter and deletes from the front of the first list as many
Write the following ML functions:
Write a function that takes two lists as parameter and deletes from the front of the first list as many elements as there are in the second list. If the first list is shorter than the second list, return nil.
Sample Run:
- dels([2,5,1,8], [4,3]); // there are 2 elements in the second list, so delete 2 elements
// from the first list
val it = [1,8] : int list
- dels([2,5], [4,5,3]); // first list is shorter so return nil
val it = [] : int list
Assuming that an int list contains the digits of an integer, write a function which takes this list as a parameter as well as an integer which is a power of 10. The function should return a list which contains the digits of their product.
Sample Run:
- mult([5,3,2],1000); // multiply 532 by 1000
val it = [5,3,2,0,0,0] : int list
Note: Write only one function for each part, and do not call any other functions
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
