Skip to content
Snippets Groups Projects
Commit 0ea0f47e authored by James R. Wilcox's avatar James R. Wilcox
Browse files

lec01.ml

parent 6778c4ec
No related branches found
No related tags found
No related merge requests found
(* welcome to 341 *)
(* a program is a sequence of bindings *)
let x = 3
let y : int = 4
(* to run a program, use utop
- utop is a REPL
- load a program from file: #use "filename.ml";;
*)
(* what do programs mean? run them and see what happens
- two phases to execution: compile-time and run-time
- at compile-time, we do type checking
- at run-time, we run stuff
*)
let z = x + y
let _ = x * (y + z)
let _ = if z > 5 then 3 else 17
(* another kind of binding: making a function *)
(* let max((a: int), (b: int)): int = *)
(* let max(a, b): int = *)
let max((a: int), (b: int)) =
if a < b then b else a
let _ = max(10, 5)
(* floats *)
(* let _ = 1.5 + 1.5 *)
let _ = 1.5 +. 1.5 *. 2. -. 1.
let _ = 1.5 +. 1.5 *. 2. -. float_of_int(1)
(* strings *)
let msg = string_of_int(17)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment