this week: discuss how to handle events in user-interface — MVC, functional reactive programming.
Traditional way of handling events: observer Pattern (MVC). Used when views need to react to change in a model.
MVC: model-view-controller for user interface
This week: scala for imperative programming.
So far: pure functional programming
→ side-effect free: therefore time doesn't matter.
Any rewriting that terminates lead to the same solution. (Churcher-Rosser Th)
Now: mutable states
Stateful objects: objects can have state that change over time. (state is influenced …
Generalize the structural induction on list to general structures like trees.
To prove a property
P(t)for all treest:
* show for any leave l,P(l)holds
* for each internal nodetwith subtreess1...sn, showP(s1)&...&P …
ex: json json objects can be seq, num, str, bool,...
⇒ represented as abstract class and case classes.

→ question: what is the type of the {case(key, value)=>"..."} clause?
it is (JBinding => String) type, which is a shorthand for Function1[JBinding, String …
so far: only seen List. → more (immutable) collections.
List: is linear -- access to head is faster than middle or end element. Vector: better rand access performance.
represented as very shallow trees(32-split at each node)

Vector support similar operations as List (head, tail,map, fold …
already known methods:
xs.head
xs.tail
sublist and ele access:
xs.lengthxs.lastxs.init: all elementh except last elementxs.take(n): sublist of first n elementsxs.drop(n): the rest of list after taking first n elementsxs(n …scala is pure OO: every value is an obj, every operation is a method of obj.
scala.Int scala.Boolean maps to JVM standard primitive types.
Implement Boolean withous primitive type in scala:
Then defin false and true as objects, give implementation for ifThenElse() funciton:
object …This week, we'll cover traits, and we'll learn how to organize classes into hierarchies. We'll cover the hierarchy of standard Scala types, and see how to organize classes and traits into packages. Finally, we'll touch upon the different sorts of polymorphism in Scala.
abstract …This week, we'll learn about functions as first-class values, and higher order functions. We'll also learn about Scala's syntax and how it's formally defined. Finally, we'll learn about methods, classes, and data abstraction through the design of a data structure for rational numbers.
higher order functions …