Programming Challenges
Explore practical programming challenges using dataflow programming with functions in OCaml. Learn to calculate the area of the largest circle, merge two data streams, and generate Fibonacci numbers using streams. This lesson develops problem-solving skills with lists, streams, and dataflow models to deepen your understanding of functional programming techniques.
We'll cover the following...
We'll cover the following...
Challenge 1: Area of the largest circle
The following algebraic datatype represents a geometric shape. For our purposes here, we’ll only consider circles and rectangles.
type shape = Circle of float
| Rectangle of float * float
The following function calculates the area of a shape:
let rec area s = ...