Solutions Manual > hw2-solution (1) McGill University COMP 302


McGill University COMP 302 (* PRELUDE *) type nat = Z | S of nat type exp = | Const of float | Var | Plus of exp * exp | Times of exp * exp | Pow of exp * int (* SOLUTION *) (* Quesiton 1 *) let rec q1a_nat_of_int (n : int) : nat = match n with | 0 -> Z | _ -> S (q1a_nat_of_int (n-1)) let rec q1b_int_of_nat (n : nat) : int = match n with | Z -> 0 | S n -> 1 + q1b_int_of_nat n ...[Show More]

Preview 1 out of 2 pages
Purchase this document to unlock the blurred part and the rest of the document

Unlock Now

Reviews( 0 )