Recitation 3
- Imagine that your boss asks you to implement a function named
grk
and that its type must be exactlystring -> bool
. In other words, the toplevel would print the following when queried about the function:# grk;; grk : string -> bool = <fun>
Use the toplevel to investigate which of the following would be permitted by your boss’s request, and which would not:
- Making
grk
a recursive function. - Making
grk
a non-recursive function. - Writing a helper function and using that helper function in the body of
grk
. -
Making the
string
argument a labelled argument.
- Making
-
Compare and contrast OCaml functions to functions in another language of your choice, focusing on those concepts: recursive vs. non-recursive, anonymous, polymorphism, and partial application.
- One of the premises of functional programming is that mathematical functions are the basic building block of computation. How are OCaml functions like mathematical functions? How are they different? As part of your answer, focus on the notion of types. In your opinion, is mathematics itself typed or untyped?
Submit your answers to CMS.