Question: In F# Language, please provide sample output. Write a function downTo : int -> int list so that downTo n returns the n-element list [n;
In F# Language, please provide sample output.
Write a function
downTo : int -> int list
so that downTo n returns the n-element list [n; n-1; . . .; 1].
You must use if-then-else expressions to define the function.
Secondly define the function downTo2 having same semantics as downTo. This time you must use pattern matching.
Write another function
removeOddIdx : int list -> int list
so that removeOddIdx xs removes the odd-indexed elements from the list xs:
removeOddIdx [x0; x1; x2; x3; x4; ...] = [x0; x2; x4; ...]
removeOddIdx [] = []
removeOddIdx [x0] = [x0]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
