When circumstances allow, I'll be typing up bits of my lecture notes and posting them online. These may or may not bear any resemblance to the actual lectures.
Here's the example we saw last class:
to initials.recursive :name
ifelse (emptyp :name)~
[output []]~
[output sentence (first (first :name)) (initials.recursive butfirst :name)]
end
The procedure stops when variable name contains the empty list. The leap of faith is the
assumption that initials.recursive can successfully output a list of initials from every item
except the first in the list contained in name. Also notice that initials.recursive
uses itself as a helper procedure unless the stop condition is met, and that it checks the stop
condition before using itself as a helper.
If you're familiar with proof by induction, you may wish to view this proof to see how the various steps align with the features in a recursive procedure.
If you haven't seen proof by induction yet, consider the following "recursive definition":
(n+1)! = (n+1) * n! (leap of faith)
0! = 1 (stop condition).
Let's use this definition to calculate the value of 3!. We don't know it directly, but we do know that 3! = 3 * 2!. Again, we don't know the value of 2!, but we can use the definition to learn that 2! = 2 * 1!. The definition says that 1! = 1 * 0!, and we've now reached our "stop condition".
We know that 0! = 1, so 1! must be 1 * 1 = 1. So 2! = 2 * 1! = 2 * 1 = 2, and 3! = 3 * 2! = 3 * 2 = 6. This is exactly how a recursive procedure would compute 3!.
Try writing a recursive procedure named factorial that accepts a positive number n as input and outputs the value n!. You may wish to use procedure initials.recursive, above, as an example.
Important note: in order to use 2! to calculate the value of 3!, we had to know the value of 2!. Your procedure will have to output its result (not print it) in order to use that result in future calculations.

The hardest part of the problem is the leap of faith. Suppose we already had a procedure that could draw a small collection of nested squares. How would we write a procedure to add one square to that collection?
What information do we need? We need the size of the new square that we're drawing, the size of the collection of squares to be drawn inside that square, and information on where to position the smaller collection of squares inside the large outer square.
We can make the size of the square we're drawing an input to our recursive procedure:
to squareview :size ; ; ; ; endThe size of the collection of squares inside the starter square will depend on the size of the starting square. After some thought, you may notice a 45-45-90 triangle at the corner of each square. If the two legs of that triangle have length :size/2, the Pythagorean theorem says that the hypotenuse must have length :size/sqrt(2).
to square :size repeat 4 [forward :size right 90] end to squareview :size square :size ; ; squareview :size / (sqrt 2) endOur procedure isn't done yet. What are we missing?
The size of the squares is dictated by the variable size, so we just stop when the squares get small enough.
to squareview :size square :size if lessp :size 2 [stop] ; squareview :size / (sqrt 2) end(What happens if we mistakenly say if lessp 2 :size? Why don't we need an output command as we did with the factorial program?)
First, figure out where your turtle will be when it finishes drawing the outside square. Then figure out where it needs to move to to draw the next square.
In this example, the turtle needs to move forward :size/2 distance, then turn to the right by 45° before starting the inside square.
to squareview :size square :size if lessp :size 2 [stop] forward :size/2 right 45 squareview :size / (sqrt 2) end