Plan (next 4 weeks)
1. Fast forward
Rapid introduction to whats in OCaml
History, Variants
Meta Language Designed by Robin Milner @ Edinburgh Language to manipulate Theorems/Proofs Several dialects:
Standard ML (of New Jersey)
Original syntax
2. Rewind
CSE 130 : Winter 2010
Recap: a quicksort function
let rec sort l = match l with [] -> [] | (h:t) -> let (l,r) = partition (<) h) t in (sort l)@(h:(sort r) ;
Programming Languages
Expressions and Types
UC San Diego
Whats the difference?
void sort(int arr[]
OCaml
The PL for the discerning hacker.
Hello.
Im Zach, one of Sorins students. [email protected]
ML Anatomy 101
ML Program = One Giant, Complex Expression ?
Controlling complexity is the essence of computer programming. B. Kerninghan A complex system
OCaml
The PL for the discerning hacker.
Hello.
Im Zach, one of Sorins students. [email protected]
ML Anatomy 101
ML Program = One Giant, Complex Expression ?
Controlling complexity is the essence of computer programming. B. Kerninghan A complex system
Recap from last Week
Three key ways to build complex types/values 1. Each-of types Value of T contains value of T1 and a value of T2
Today
More on recursion Higher-order functions
taking and returning functions
2. One-of types Value of T contains value
Admin stuff
PA 3 due Sunday 5pm Midterm Tuesday Oct 26
covers all of Ocaml, but only PA1-PA3
Recap: max function
let max x y = if x < y then y else x; (* return max element of list l *) let list_max l = let rec helper curr l = match l with [] -> curr |
Other kinds of polymorphisms
Sub-type polymorphism
void f(Shape s)
Other kinds of polymorphisms
Bounded polymorphism
Like parametric, except can provide a bound
void proc_elems(list[T]) WHERE T <= Printable
Can pass in any sub-type of Shape
Parametri
Annoucements
Midterm on Tuesday PA 4 due Friday a week from tomorrow KQS on Thursday Dude, whats KQS?
KQS
Handout a sheet with three questions:
what things do you want me to Keep doing? what things do you want me to Quit doing? what things do you want
Midterm Solutions
Recap from last Python lecture
Interpreted, imperative, OO Language Everything is an object Dynamic Typing Programs are made up of: Expressions Statements
Assignment if/elif/else while-loops Functions
Classes (still to come)
Show recap
Key data structure: Dictionaries
Associative arrays, Hash tables A table storing a set of keys, And a value for each key. Any (immutable) object can be a key! int,float,string,tuples Very useful!
Using Dictionaries
Unsorted list of key,value pairs Empty D
KQS results
Person 1: Keep Throwing candy Person 2: Stop Throwing candy Person 1: HW too easy! Person 2: HW too hard! I read all of the KQS I will keep all the comments in mind
KQS: Broad Trends
Post assignments earlier (eg: not Monday) Cover material e
Why study PL ? (discussion)
CSE 130 : Fall 2010
Programming Languages
Sorin Lerner UC San Diego
Why study PL ?
A different language is a different vision of life - Fellini - Hypothesis: Programming language shapes programming thought - Characteristics of