Question: F Sharp programming Also given the following: type env = (string * int) list let rec lookup (env: env) x = match env with |

F Sharp programming

F Sharp programming Also given the following: type env = (string *

Also given the following:

type env = (string * int) list

let rec lookup (env: env) x = match env with | (y, v) :: r -> if x = y then v else lookup r x | [] -> failwith (x + " not found")

In this problem we will consider a variation of the datatype expr where we represent operators with an enumeration type instead of the string type and we add support for variables, to represent arithmetic expressions with variables type oper Neg Not type oper2 Add Mul Sub Less Eq And type aexpr I C of int I V of string l Op1 of operaexpr l Op2 of oper2aexpr aexpr With the two datatypes above, an expression like - (+3), say, is represented as Op2 (Mul, op1(Neg, Var "x"), (Add , Var "y", c 3) ) . Similarly, an expression like (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!