Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

F Sharp programming

image text in transcribed

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

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

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions