Substitution using let
We often need local variables in our functions other than those defined as formal parameters. The ML
function let allows for definition and substitution of local variables. We illustrate its use through the
following example. Exampl
Asymptotic analysis and Orders of growth
You may have noticed that there was something unsatisfactory about our way of doing things
the calculation was tuned too closely to our machine. The figure of 104 2 n seconds is a bit
arbitrary the time to execute
Functions as inductively defined computational processes
All the examples we have presented so far are of functions which can be evaluated by substitutions or
by evaluation of conditions. In what follows we give an example of an inductively defined functi
Relations and Functions
A binary relation from A to B is a subset of A B. It is a characterization of the intuitive notion that some
of the elements of A are related to some of the elements of B. Familiar binary relations from N to N are
=, 6=, , . Thus t
GCD of two integers a, b > 0 is defined as maxcfw_x : x is an integer, x > 0, x | a, x | b, where the notation x
| a means x divides a. Consider the following algorithm for computing GCD using pencil and paper:
gcd(a, b) = a if a = b gcd(a b, b)
Definition of functions using conditionals
In this section we give a few examples of function definitions using conditionals. Example 3.5 Finding the
larger of two numbers. Let us define a function max : NN N.The domain set for this function is the
MAT 133Y COURSE OUTLINE AND HOMEWORK PROBLEMS, 2016-2017
NEW THIS YEAR: The one and only calculator you will be permitted
to use on quizzes, tests, and exams is the TI-30XIIS. NO OTHER CALCULATOR OF ANY KIND WILL BE PERMITTED.
Required reading: Chapter 3,16
Please review the Joe Martin chapter from our history session; specifically, remind
yourself of The Diamond.
After considering the interdependence of business and society, we will e
MAT 133Y TUTORIALS AND QUIZZES
September 16, 2016
Tutorials begin the week of Sept. 26.
Tutorial Registration: Most of you already have a tutorial, but several dozen do not.
Please register for a TUT section right away. If your name is not on your TAs cla