lecture-2

lecture-2 - Plan (next 4 weeks) 1. Fast forward Rapid...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Plan (next 4 weeks) 1. Fast forward • Rapid introduction to what’s in OCaml 2. Rewind 3. Slow motion • Go over the pieces individually History, Variants “Meta Language” • Designed by Robin Milner @ Edinburgh • Language to manipulate Theorems/Proofs • Several dialects: – Standard” ML (of New Jersey) • Original syntax – “O’Caml: The PL for the discerning hacker” • French dialect with support for objects • State-of-the-art • Extensive library, tool, user support • (.NET) ML’s holy trinity • Everything is an expression • Everything has a value • Everything has a type Expression Value Type Interacting with ML “Read-Eval-Print” Loop Repeat: 1. System reads expression e 2. System evaluates e to get value v 3. System prints value v and type t What are these expressions , values and types ? Base type: Integers Complex expressions using “operators”: (why the quotes ?) • +, -, * • div, mod 2 2 int 2+2 4 2 * (9+10) 38 2 * (9+10) -12 26 Base type: Strings Complex expressions using “operators”: (why the quotes ?) • Concatenation ^ “ab” “ab” string “ab” ^ “xy” “abxy”
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Base type: Booleans Complex expressions using “operators”: • “Relations”: = , <, <=, >= true true bool false false 1 < 2 true “aa” = “pq” false (“aa” = “pq”) && (1<2) false (“aa” = “pq”) && (1<2) true Type Errors Untypable expression is rejected • No casting or coercing • Fancy algorithm to catch errors • ML’s single most powerful feature (2+3) || (“a” = “b”) (2 + “a”) “pq” ^ 9 Complex types: Product (tuples) (2+2 , 7>8); (4,false) int * bool Complex types: Product (tuples) (9-3,“ab”^“cd”,(2+2 ,7>8)) (6, “abcd”,(4,false)) (int * string * (int * bool)) • Triples,… • Nesting: – Everything is an expression , nest tuples in tuples Complex types: Lists []; [] ’a list • Unbounded size • Can have lists of anything • But… [1;2;3]; [1;2;3] int list [“a”;“b”; “c”^“d”];
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 6

lecture-2 - Plan (next 4 weeks) 1. Fast forward Rapid...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online