- Evaluate the header’s expression.
- If it’s a true value, execute the (whole) suite, then return to step 1.
Iteration Demo - The Fibonacci Sequence
Three characteristics of functions that are really important:
- A function’s domain is the set of all inputs it might possibly take as arguments.
- A function’s range is the set of output values it might possible return.
- A pure function’s behavior is the relationship it creates between input and output.
A Guide to Designing Functions
- Give each function eactly one job, but make it apply to many related situations
- Don’t repeat yourself. Implement a process just once.
>>> round(1, 23) 1 >>> round(1.23, 1) # round to 1 decimal place 1.2 >>> round(1.23, 0) # roudn to integer 1
Generalizing Patterns with Arguments
The area example
Higher Order Functions
Generalizing over Computational Processes
A higher order function is a function that takes in another function as an argument.
Locally Defined Functions
Functions defined within other function bodies are bound to names in a local frame.
An operator is any expression that evaluates to a function. So, in
make_adder(1) is the operator.
Hey! Thanks for reading :P I just want to let you know that if you enjoyed this, you might also like this post on Lecture 3 – Controls.