1))))))) (hofstadter-male-female 8) ===> ((1 . 0) (1 . 0) (2 . 1) (2 . 2) (3 . 2) (3 . 3) (4 . 4) (5 . 4) (5 . 5)) (See Hofstadter's male and female sequences for the definitions used in this example.) All procedures bound in a single letrec may refer to one another by name, as well as to values of variables defined earlier in the same letrec, but they may not refer to values defined later in the same letrec. A variant of let, the "named let" form, has an identifier after the let keyword. This binds the let variables to the argument of a procedure whose name is the given identifier and whose body is the body of the let form. The body may be repeated as desired by calling the procedure. The named let is widely used to implement iteration. Example: a simple counter (let loop ((n 1)) (if (> n 10) '() (cons n (loop (+ n 1))))) ===> (1 2 3 4 5 6 7 8 9 10) Like any procedure in Scheme, the procedure created in the named let is a first-class object. Proper tail recursion Scheme has an iteration construct, do, but it is more idiomatic in Scheme to use tail recursion to express iteration. Standard-conforming Scheme implementations are required to optimize tail calls so as to support an unbounded number of active tail calls (R5RS sec. 3.5)—a property the Scheme report describes as proper tail recursion—making it safe for Scheme programmers to write iterative algorithms using recursive structures, which are sometimes more intuitive. Tail recursive procedures and the named let form provide support for iteration using tail recursion. ;; Building a list of squares from 0 to 9: ;; Note: loop is simply an arbitrary symbol used as a label. Any symbol will do. (define (list-of-squares n) (let loop ((i n) (res '())) (if (< i 0) res (loop (- i 1) (cons (* i i) res))))) (list-of-squares 9) ===> (0 1 4 9 16 25 36 49 64 81) First-class continuations Continuations in Scheme are first-class objects. Scheme provides the procedure call-with-current-continuation (also known as call/cc) to capture the current continuation by packing it up as an escape procedure bound to a formal argument in a procedure provided by the programmer. (R5RS sec. 6.4) First-class continuations enable the programmer to create non-local control constructs such as iterators, coroutines,