; file: test-show.scm ; author: Robert Keller ; purpose: testing of the "show" wrapper ; For any expression exp ; (show exp) ; will print the expression exp and return its value. ; It can thus be wrapped around any expression that is evaluated for a value. (load "show.scm") ; This version uses the expression as a message (define (fac1 n) (if (< n 1) 1 (show (* n (fac1 (- n 1)))))) (fac1 5) ; In this version, show-message, both a message and a value are specified. ; We can use back-quote comma combination, if desired, to get an expression that ; is part literal, part evaluated. (define (fac2 n) (show-message `(fac2 ,n) ;; back-quote comma convention. The comma specifies to evaluate. (if (< n 1) 1 (* n (fac2 (- n 1)))))) (fac2 5) ;The output of this program is: ; ;showing value of (* n (fac1 (- n 1))): 1 ;showing value of (* n (fac1 (- n 1))): 2 ;showing value of (* n (fac1 (- n 1))): 6 ;showing value of (* n (fac1 (- n 1))): 24 ;showing value of (* n (fac1 (- n 1))): 120 ;120 ;(fac2 0): 1 ;(fac2 1): 1 ;(fac2 2): 2 ;(fac2 3): 6 ;(fac2 4): 24 ;(fac2 5): 120 ;120