Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Rewriting OCaml definitions to an equivalent form (parts 1a - 1c) 1. Rewrite each of the following OCaml definitions to an equivalent form by adding
Rewriting OCaml definitions to an equivalent form (parts 1a - 1c)
1. Rewrite each of the following OCaml definitions to an equivalent form by adding trailing integers to each identifier, using as many distinct integers as possible. Use the integers in order 0, 1, 2, .... For example, for 'fun a -> fun b -> (fun a -> a) (a + b)' you would write fun ao -> fun b1 -> (fun a2 -> 2) (a + b1)'. Or, if it's not possible to rewrite as requested, explain why not. la (2 minutes). lb (3 minutes). let rec f x = f x type ('nonterminal, 'terminal) symbol = | N of 'nonterminal | T of 'terminal let a a a = function |,a,_) -> a lc (4 minutes). 2. Convert each of the definitions (la), (b), (1c) into a simple form with no shorthand. In the simple form, every 'let' should be of the form 'let ID = EXPR', every lambda expression should be of the form 'fun ID -> EXPR', where ID stands for a single identifier and EXPR for a single expression. Or, if it's not possible to rewrite a (Problem values are the definition as requested, explain why not. same as for problem 1.) 3. For each of the definitions (la), (1b), (lc), list the types of (An identifier is "top-level" if it is every top-level identifier. Or, if it's not visible to later definitions in the same program. ) possible to list a top-level identifier's type, explain why not. (Problem values are the same as for problem 1.)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