Export to GitHub

mathcourse - 2009_Foundations_Hanoi_Exercises.wiki


Homework Problems for June 10 lecture:

  1. Write an OCaml function curry that curries a function.
  2. Write an OCaml function uncurry that uncurries a function.
  3. Write an OCaml function that takes a string, treats it as a base 256 numeral, and returns the int that it corresponds to.
  4. Write an OCaml that converts an integer to the string giving the base 256 numeral.
  5. Write an OCaml that takes an integer and a base and returns the list of digits in that base, each digit represented as an integer.
  6. Write an OCaml function that takes a natural number, and if it has the form of a list of natural numbers, returns the OCaml list.
  7. Write an OCaml function that takes computes the value of the serial pair
  8. Write an OCaml function that takes two functions of type :int -> int and returns the composite of the two functions: composite f g
  9. Show on paper that the composites composite curry uncurry and composite uncurry curry are both the identity.
  10. Describe an injective function from the set of finite sets of natural numbers to the set of natural numbers.
  11. Implement this function in OCaml as a function of type :int list -> int

  12. What function results by recursion if a = 1 and b(n,s) = n*s?

  13. What function results by recursion if a = 0 and b(n,s) = n+s?
  14. What function results by recursion if a = 1 and b(n,s) = 2*n?
  15. Give a recursive function in OCaml that to k returns the sum of the first k odd natural numbers.
  16. Give a recursive function in Ocaml that to k returns the sum of the first k cubes. f(0) = 0, f(1) = 1, f(2) = 9