Skip to content

Instantly share code, notes, and snippets.

@davydovanton
Created November 1, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davydovanton/eeb2c941eb5ef25d8583 to your computer and use it in GitHub Desktop.
Save davydovanton/eeb2c941eb5ef25d8583 to your computer and use it in GitHub Desktop.
scheme example
(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