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
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
Get step-by-step solutions from verified subject matter experts
