Commit 3103dced authored by Dan Grossman's avatar Dan Grossman
Browse files

lecture and lec01 copied from au

parent ef8d4fca
(* Our first OCaml program.
This is a comment.
(* Comments can nest. *)
*)
(* These two lines will be at the top of provided lecture code
just to make the repl cleaner for teaching. You can leave
them commented out, or not, or use them in your homework,
or not, as you wish. *)
#utop_prompt_dummy
let _ = UTop.set_show_box false
(* static env = ... *)
(* dynamic env = ... *)
let x = 34
(* static env = ...; x : int *)
(* dynamic env = ...; x -> 34 *)
let y = 17
(* static env = ...; x : int; y : int *)
(* dynamic env = ...; x -> 34; y -> 17 *)
let z = (x + y) + (y + 2)
(* static env = ...; x : int; y : int; z : int *)
(* dynamic env = ...; x -> 34; y -> 17; z -> 70 *)
let q = z + 1
(* static env = ...; x : int; y : int; z : int; q : int *)
(* dynamic env = ...; x -> 34; y -> 17; z -> 70; q -> 71 *)
let abs_of_z =
if z < 0 then
-z
else
z
(* static env = ...; x : int; y : int; z : int; q : int; abs_of_z : int *)
(* dynamic env = ...; x -> 34; y -> 17; z -> 70; q -> 71; abs_of_z -> 70 *)
let abs_of_z_simpler = Int.abs z
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment