Answered step by step
Verified Expert Solution
Question
1 Approved Answer
let t7 = Fork (Some 1, Leaf (Some 2), Fork (Some 3, Leaf None, Leaf None)) let t8 = Fork (Some a, Leaf (Some b),
let t7 = Fork (Some 1, Leaf (Some 2), Fork (Some 3, Leaf None, Leaf None)) let t8 = Fork (Some "a", Leaf (Some "b"), Fork (Some "c", Leaf None, Leaf (Some "d")))
Write 4 new functions
t_opt_size : 'a option tree -> int
Example: t_opt_size t7 gives 3.
t_opt_sum : int option tree -> int
Example: t_opt_sum t7 gives 6.
t_opt_charcount : string option tree -> int
Example: t_opt_charcount t8 gives 4.
t_opt_concat : string option tree -> string
Example: t_opt_concat t8 gives "abcd".
(program in ocaml)
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