






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







CMSC 330 2
CMSC 330 3
CMSC 330 4
match e with p1 -> e1 | ... | pn -> en
let is_empty l = match l with [] -> true | (h::t) -> false
is_empty [] (* evaluates to true ) is_empty [1] ( evaluates to false ) is_empty [1;2;3] ( evaluates to false *)
CMSC 330 7
CMSC 330 8
let plus (x, y) = x + y;; plus (3, 4);;
CMSC 330 9
CMSC 330 10
CMSC 330 13
type my_type = int * (int list) (3, [1; 2]) : my_type
type my_type2 = int * char * (int * float) (3, ‘a’, (5, 3.0)) : my_type
CMSC 330 14
CMSC 330 15
CMSC 330 16
CMSC 330 19
let rec fact n = if n = 0 then 1 else n * fact (n-1);;
CMSC 330 20
CMSC 330 21
CMSC 330 22
let rec print_up_to (n, m) = print_int n; print_string "\n"; if n < m then print_up_to (n + 1, m)