Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ocaml! (* TODO: write a fubction that reads bool trees : for all (finite) t : bool trees. read_bool_tree t = Some (show_bool_tree t) For

Ocaml! (*

TODO: write a fubction that reads bool trees :

for all (finite) t : bool trees.

read_bool_tree t = Some (show_bool_tree t)

For example,

read_bool_tree "true" = Some (Leaf true)

read_bool_tree "false" = Some (Leaf false)

read_bool_tree "tralse" = None

read_bool_tree "(true^false)" = Some (Node (Leaf true, Leaf false))

read_bool_tree "((true^(true^false))^((true^(true^false))^false))" =

Some

(Node (Node (Leaf true, Node (Leaf true, Leaf false)),

Node (Node (Leaf true, Node (Leaf true, Leaf false)), Leaf false)))

*)image text in transcribed

(* the type of a plymorphic tree *) type 'a tree - | Leaf of 'a Node of 'a tree * 'a tree (* standard functions to convert between strin and char list *) let explode s = let rec exp i l = if i res | C :: 1 -> res. [i] ((bool * (char list)) option) such that read_bool_prefix (explode "true???") = Some (true, ['?'; '?'; '?']) read_bool_prefix (explode "false123") = Some (false, ['1'; '2'; '3']) read_bool_prefix (explode "antythingales") = None read_bool_prefix [] = None write a helper function read_bool_tree_prefix (char list) -> ((bool tree * (char list)) option) such that read_bool_tree_prefix [] = None read_bool_tree_prefix (explode "true???") = Some (Leaf true, ['?'; '?'; '?'1) read_bool_tree_prefix (explode "(true false) 124") Some (Node (Leaf true, Leaf false), ['1'; '2'; '4']). read_bool_tree_prefix (explode "(true"(true false))aaa") = Some (Node (Leaf true, Node (Leaf true, Leaf false)), ['a'; 'a'; 'a']). read_bool_tree_prefix (explode "(true^(truefa se)) aaa") = None let rec read_bool_tree (tree: string) : ((bool tree) option) = failwith "unimplemented

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Did the team members feel that their work mattered

Answered: 1 week ago