In this lecture, we discussed some more core SML language features that we can use to write more useful SML programs.
We introduced tuples, which are collections of multiple values. We learned that tuples have their own tuple types, or product types, which tells us how many entries are in the tuple, and what the types of its components are.
We also learned more about functions, specifically about the anonymous lambda expression, which is a function expression which does not have a name. Since functions are values, these lambda expressions can be bound to variables like normal values.
Binding and scope was introduced, which is one of the primary differentiators between functional and non-functional languages. This plays into our ideal of modularity, because binding forbids functions from exhibiting differing behavior depending on bindings that occur after it was originally declared.
We also saw patterns, which are the basic constructs we use in order to deconstruct and branch our programs based on the structure of a value. These include wildcards, variables, tuples, and constants.
Functional programming gives us mathematical tools to understand our code, and we learned about a few. We learned about the concept of extensional equivalence, which relates SML expressions which exhibit the same behavior. Referential transparency lets us substitute these expressions for each other freely, allowing us to reason equationally about SML expressions in the same way that we do about math.
The five-step methodology was also introduced, which consists of properly documenting and testing our code, by explicitly writing out types, preconditions, and postconditions, as well as unit tests that demonstrate the behavior of a function.