Question: PLEASE READ!!!! please have the code in Ocaml not Python. Part 1 : Non - Recursive Functions Implement the following functions that do not require
PLEASE READ!!!! please have the code in Ocaml not Python.
Part : NonRecursive Functions
Implement the following functions that do not require recursion. Accordingly, these functions are defined
without the rec keyword, but you MAY add the rec keyword to any of the following functions or write a
recursive helper function. Just remember that if you write a helper function, it must be defined in the file
before it is called.
revtup tup:a b
Type: a b c c b a
Description: Returns a tuple in the reverse order of tup
Examples:
revtup
revtup
revtriple triple:a b c
Type: a b c c b a
Description: Returns a triple in the reverse order of triple
Examples:
riple
riple
riple
isoddx:int
Type: int bool
Description: Returns whether or not x is odd.
Examples:
true
false
true isolderdate :int int int date:int int int
Type: int int intint int int bool
Description: Returns whether date comes before the date
Examples:
isolder false
isolder false
isolder false
isolder true
tousformatdate :int int int
Type: int int intint int int
Description: Convert date which appears as Year Month, Day to US format Month Day, Year
Examples:
tousformat
tousformat
tousformat
tousformat
Part : Recursive Functions
Implement the following functions using recursion.
pow x:int, p:int
Type: int int int
Description: Returns raised to the power p
Assumptions: p is nonnegative, and we will not test your code for integer overflow cases.
Examples:
pow
pow
pow
fac x:int
Type: int int
Description: Returns the factorial of x as an integer.
Assumptions: You may assume the answer is nonnegative,
Examples:
fac
fac
fac
fac
getnth idx : intlst: 'a list
Type: int 'a list a
Description: Returns the element at the index idx in the list lst
Assumptions: idx is nonnegative.
Examples:
README
;;
;
;
larger lst: 'a listlst: 'a list
Type: 'a list 'a list 'a list
Description: Returns the longer list provided as an argument, returns the
empty list if the two lists are the same length.
Examples:
larger
larger ;;
larger ;;
larger ;;;;
sumlst: int listlst: int list
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
