[SOLVED] CS代写

30 $

File Name: CS代写.zip
File Size: 75.36 KB

SKU: 2943128097 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


exception TypeError
exception UndefinedVar
exception DivByZeroError

Copyright By PowCoder代写加微信 assignmentchef

(* Remove shadowed bindings *)
let prune_env (env : environment) : environment =
let binds = List.sort_uniq compare (List.map (fun (id, _) -> id) env) in
List.map (fun e -> (e, List.assoc e env)) binds

(* Env print function to stdout *)
let print_env_std (env : environment): unit =
List.fold_left (fun _ (var, value) ->
match value with
| Int_Val i -> Printf.printf “- %s => %s
” var (string_of_int i)
| Bool_Val b -> Printf.printf “- %s => %s
” var (string_of_bool b)
| Closure _ -> ()) () (prune_env env)

(* Env print function to string *)
let print_env_str (env : environment): string =
List.fold_left (fun acc (var, value) ->
match value with
| Int_Val i -> acc ^ (Printf.sprintf “- %s => %s
” var (string_of_int i))
| Bool_Val b -> acc ^ (Printf.sprintf “- %s => %s
” var (string_of_bool b))
| Closure _ -> acc
) “” (prune_env env)

(***********************)
(****** Your Code ******)
(***********************)

(* evaluate an arithmetic expression in an environment *)
let rec eval_expr (e : exp) (env : environment) : value =

(* evaluate a command in an environment *)
let rec eval_command (c : com) (env : environment) : environment =

程序代写 CS代考加微信: assignmentchef QQ: 1823890830 Email: [email protected]

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS代写
30 $