Question
Ocaml language Problem 1: Assume the following type definition: type student = {first_name : string; last_name : string; gpa : float} Give OCaml expressions that
Ocaml language
Problem 1: Assume the following type definition: type student = {first_name : string; last_name : string; gpa : float} Give OCaml expressions that have the following types: student student -> string * string (a function that extracts the students name) string -> string -> float -> student (a function that creates a student record)
Problem 2: Write a function safe_hd : 'a list -> 'a option that returns Some x if the head of the input list is x, and None if the input list is empty. Also write a function safe_tl : 'a list -> 'a list option that returns the tail of the list, or None if the list is empty.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started