Higher-Order Functions, Tuples,
same_arg twice
The purpose of this question is to help the student master:
• pattern matching, which is a major method used in functional programming.
Using VSCode – General Instructions
Problem
Write a function same_arg_twice : (a ‘b)
“b that takes a function and then an
argument as inputs and returns the result of applying the function to the argument and applying the
resultant function to the argument a second time.
map triple
The purpose of this question is to help the student master:
• pattern matching, which is a major method used in functional programming.
Write a function map triple that takes a function and
then a triple of inputs and returns the triple where each element id the result of applying the function to
each corresponding element in the input triple.
Pattern Matching, Recursion, naive
fibonacci
The purpose of this question is to help the student master: recursion
Problem
• The Fibonacci number for any integer less than or equal to 1 is 1 and after that, the n’ Fibonacci number
is the sum of the two preceding Fibonacci numbers in the sequence, for n > 1. Write an OCaml function
naive_fibonacci : int -› int that, when applied to an integer n returns the nth Fibonacci number. Do
not worry about be efficient at this time; we will discuss topics related to the efficiency of recursive
functions in a the next one to two weeks.