Welcome to the CHICKEN Scheme pasting service

alternative coops define-class added by DerGuteMoritz on Fri Aug 24 17:56:36 2012

(define-class* <account> () self
  ((balance 0) (transactions '()))

  ((account-balance)
   (balance self))

  ((transact! amount)
   (set! (transactions self) (alist-cons (current-seconds) amount (transactions self)))
   (set! (balance self) (+ (balance self) amount)))

  ((credit! amount)
   (transact! self amount))

  ((debit! amount)
   (transact! self (- amount))))


(define acc (make <account>))

(test 0 (account-balance acc))
(credit! acc 100)
(debit! acc 20)
(test 80 (account-balance acc))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which egg provides `take-right'?
Visually impaired? Let me spell it for you (wav file) download WAV