{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture-2

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

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

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”

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

View Full Document
2 Base type: Booleans Complex expressions using “operators”: • “Relations”: = , <, <=, >= &&, ||, not 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 []; []
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online