, . , . - , ; , , . , ; , , , . , . :
(define (some-function x y)
(preprocess x)
(combine (modified x) y))
(some-function alpha beta)
some-function, : , .. (preprocess x). some-function , some-function, preprocess. , preprocess . modified; , modified , combine. , , combine, some-function — some-function , ! , , ; combine , . (combine (modified x) y) - , .
, :
(define (my-while cond body)
(when (cond)
(body)
(my-while cond body)))
(let ((i 0))
(my-while (lambda () (< i 10))
(lambda () (display i) (newline) (set! i (+ i 1)))))
, my-while. , , my-while cond body , , .
-, . display, . - : define, , .. , s- , " ". , , - , .
, , :
(require (lib "string.ss"))
(define (print-report width . nvs)
(if (null? nvs)
(void)
(let ((name (car nvs))
(value (cadr nvs)))
(display (format "~a:~a $~a~n"
name
(make-string (- width (string-length name) 2) #\-)
(real->decimal-string value 2)))
(apply print-report width (cddr nvs)))))
(define (ab-income)
(display "Income: ")
(let ((income (string->number (read-line))))
(if (or (not income) (<= income 600))
(begin (display "Please enter an amount greater than $600.00\n\n")
(ab-income))
(begin (newline)
(print-report 40 "Deduct for bills" (* 3/10 income)
"Deduct for taxes" (* 2/10 income)
"Deduct for savings" (* 1/10 income)
"Remainder for checking" (* 4/10 income))))))
-, , mzscheme (require (lib "string.ss")) real->decimal-string. display, . , 40- , . , print-report. - ; 40. - . ( ) , , . format display . ( , ).
(display "Income: ") let; , ? if, , input false, , string->number . , , , , , . (, , print-report display format s.)
, ; , , .