[SOLVED] CS计算机代考程序代写 open Types

30 $

File Name: CS计算机代考程序代写_open_Types.zip
File Size: 376.8 KB

SKU: 0929166376 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


open Types
open Format

let string_of_const =
function True -> “true”
| False ->”false”
| Int n -> string_of_int n
let string_of_op =
function
Plus -> “(+)”
| Minus -> “(-)”
| Times -> “(*)”
| Div -> “(/)”
| Lt -> “(<)”| Gt -> “(>)”
| Le -> “(<=)”| Ge -> “(>=)”
| Eq -> “(=)”
| And -> “(&&)”
| Or -> “(||)”

let rec fprint_val f =
function Const c -> fprintf f “%s” (string_of_const c)
| Fun (x, e) -> fprintf f “@[ fun %s ->@ %a@]” x fprint_exp e
| Op o -> fprintf f “%s” (string_of_op o)
and fprint_exp f =
function Var v -> fprintf f “%s” v
| Value v -> fprint_val f v
| Let (x, e1, e2) ->
fprintf f “@[ let %s =@ %a@ in@ @[ %a@]@]”
x
fprint_exp e1
fprint_exp e2
| If (e1, e2, e3) ->
fprintf f “@[ if@ %a@ then@ %a@ else@ %a@]”
fprint_exp e1
fprint_exp e2
fprint_exp e3
| App (e1, e2) ->
fprintf f “@[ app@ %a@ to@ %a@]”
fprint_exp e1
fprint_exp e2
let pprint_exp e =
(fprint_exp Format.std_formatter e;
Format.print_newline ())

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] CS计算机代考程序代写 open Types
30 $