A procedure body can contain calls to other procedures, not least itself: (define factorial (lambda (n) (if (= n 0) 1 (* n (factorial (- n 1)))))) This recursive procedure calculates the factorial of a number. If the number is 0, the answer is 1. For…
Jumps One of the signal features of Scheme is its support for jumps or nonlocal control. Specifically, Scheme allows program control to jump to arbitrary locations in the program, in contrast to the more restrained forms of program control flow allow…
Scheme <How to Design Programs : An Introduction to Programming and Computing>(<程序设计方法>) <Structure and Interpretation of Computer Programs> <The Little Schemer> <The Seasoned Schemer> <The Scheme Programming Language>…
Drracket continuation 文中使用let/cc代替call/cc Racket文档中,let/cc说明为: (let/cc k body ...+) Equivalent to (call/cc (lambda (k) body ...)). 首先,通过一个简单的函数来测试下continuation,注意,下面的函数执行会导致无限循环 #lang racket (define r #f) (define (f) (let/cc k ;开始捕获continuation,从let/…