Created
November 1, 2015 14:04
-
-
Save davydovanton/eeb2c941eb5ef25d8583 to your computer and use it in GitHub Desktop.
scheme example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-account balance) | |
(define (withdraw amount) | |
(if (>= balance amount) | |
(begin (set! balance (- balance amount)) | |
balance) | |
"Недостаточно денег на счете")) | |
(define (deposit amount) | |
(set! balance (+ balance amount)) | |
balance) | |
(define (dispatch m) | |
(cond ((eq? m ’withdraw) withdraw) | |
((eq? m ’deposit) deposit) | |
(else (error "Неизвестный вызов -- MAKE-ACCOUNT" | |
m)))) | |
dispatch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment