Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

When are Einstein Reply Recommendations refreshed? ? p-968

Answered: 1 week ago

Question

Discuss the five steps that can be used to conduct a task analysis

Answered: 1 week ago

Question

Discuss the purpose and advantages of conducting a needs assessment

Answered: 1 week ago