Question: Define a function called pow ( val pow = fn : int * int - > int ) that takes two integers as arguments and
Define a function called pow val pow fn : int int int that takes two integers as arguments and that returns the result of raising the first integer to the power of the second. You may assume that the power is not negative. For our purposes, we will assume that every integer to the power is this isn't true of but that's okay
Define a function called sumTo val sumTo fn : int real that accepts an integer n and that computes the sum of the first n reciprocals. For example, sumTo should return The function should return if n is You may assume that the function is not passed a negative value of n
Define a function called repeat val repeat fn : string int string that takes a string and an integer as arguments and that returns a string composed of the given number of occurrences of the string. For example, repeathello returns "hellohellohello", repeathello returns You may assume that the function is not passed a negative value for the second argument.
Define a function called binary val binary fn: int string that takes an integer n as an argument and returns a string corresponding to the bit binary representation of that integer. For example, binary returns You need not account for numbers whose binary representation requires more than bits. Note: If needed, you can use the Int.toString function to convert integers to corresponding strings. You may find it helpful to write a helper function for this problem.
Define a function called countNegative val countNegative fn : int list int that takes a list of integers as an argument and that returns a count of the number of negative integers in the list. For example, countNegative~~ should return
Define a function called absList val absList fn : int int list int int list that takes a list of int int tuples and that returns a new list of int int tuples where every integer is replaced by its absolute value. For example, absList~~~~ should return HINT: This is easier to solve if you write a helper function to process one tuple.
Define a function called split val split fn : int list int int list that takes a list of integers as an argument and that returns a list of the tuples obtained by splitting each integer in the list. Each integer should be split into a pair of integers whose sum equals the integer and which are each half of the original. For odd numbers, the second value should be one higher than the first. For example, split should return You may assume that all of the integers in the list passed to the function are greater than or equal to
Define a function called isSorted val isSorted fn : int list bool that takes a list of integers and that returns whether or not the list is in sorted nondecreasing order true if it is false if it is not By definition, the empty list and a list of one element are considered to be sorted.
Define a function called collapse val collapse fn : int list int list that takes a list of integers as an argument and that returns the list obtained by collapsing successive pairs in the original list by replacing each pair with its sum. For example, collapse should return because the first pair and is collapsed into its sum the second pair and is collapsed into its sum and the third pair and is collapsed into its sum If the list has an odd length, the final number in the list is not collapsed. For example, collapse should return
Define a function called insert val insert fn : int int list int list that takes an integer and a sorted nondecreasing integer list as parameters and that returns the list obtained by inserting the integer into the list so as to preserve sorted order. For example, insert should return
Define a function called decimal val decimal fn: string int that takes a bit string corresponding to an integer and returns the decimal value of that integer. For example, decimal returns decimal returns
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
