(define (tak x y z) (if (not (< y x)) z (tak (tak (-1+ x) y z) (tak (-1+ y) z x) (tak (-1+ z) x y)))) ;;; (tak 18 12 6) (define (constant-access-time) (define (test-loop x) (when (not (zero? x)) (test-loop (- x 1)))) (timer (test-loop 10000))) (define (parameter-access-time) (define (test-loop x y) (when (not (zero? x)) (test-loop (- x y) y))) (timer (test-loop 10000 1))) (define (lexical-access-time) (let ((y 1)) (define (test-loop x) (when (not (zero? x)) (test-loop (- x y)))) (timer (test-loop 10000)))) (define (lexical-access-time-2) (let ((y 1)) (let ((z 2)) (define (test-loop x) (when (not (zero? x)) (test-loop (- x y)))) (timer (test-loop 10000))))) (define **y** 1) (define (global-access-time) (define (test-loop x) (when (not (zero? x)) (test-loop (- x **y**)))) (timer (test-loop 10000))) (define (fluid-access-time-1) (define (test-loop x) (when (not (zero? x)) (test-loop (- x (fluid y))))) (timer (fluid-let ((y 1)) (test-loop 10000)))) (define (fluid-access-time-2) (define (test-loop x) (when (not (zero? x)) (test-loop (- x (fluid y))))) (timer (fluid-let ((y 1) (z 3)) (test-loop 10000)))) (define (fluid-access-time-3) (define (test-loop x) (when (not (zero? x)) (test-loop (- x (fluid y))))) (timer (fluid-let ((y 1) (x 2) (z 3)) (test-loop 10000)))) (define (fluid-access-time-4) (define (test-loop x) (when (not (zero? x)) (test-loop (- x (fluid y))))) (timer (fluid-let ((y 1) (x 2) (z 3) (w 4)) (test-loop 10000)))) (define (lambda-time) (define (test-loop x) (when (not (zero? x)) (test-loop ((lambda (x y) (- x y)) x 1)))) (timer (test-loop 10000))) (define (funcall-time) (define (test-loop x f) (when (not (zero? x)) (test-loop (f x 1) f))) (timer (test-loop 10000 (lambda (x y) (- x y))))) (define (global-funcall-time) (define (test-loop x f) (when (not (zero? x)) (test-loop (f x 1) f))) (timer (test-loop 10000 -))) (define (apply-time) (define (test-loop x) (when (not (zero? x)) (test-loop (- x (apply - '(2 1)))))) (timer (test-loop 10000)))