1 / 10

Bank Account Environment Model Examples

Bank Account Environment Model Examples. Prof. Tony White April 2010. Example Bank Account: Code. (define new-withdraw      (let (( balance 100))        (lambda (amount)              (if (>= balance amount)                 

symona
Download Presentation

Bank Account Environment Model Examples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bank AccountEnvironment Model Examples Prof. Tony White April 2010

  2. Example Bank Account: Code (define new-withdraw      (let (( balance 100))        (lambda (amount)              (if (>= balance amount)                  (begin                      (set! balance (- balance amount))                      balance)                      "Insufficient funds") ) )) (define  a1 (new-withdraw 30)) (define a2 (new-withdraw 40))

  3. Example: new-withdraw let’ Π=9

  4. Example: new-withdraw let’ new-withdraw’ Π=4 Π=9

  5. Example: new-withdraw let’ Π=10

  6. Example Bank Account: Code (define(new-withdraw) (let (( balance 100))        (lambda (amount)              (if (>= balance amount)                  (begin                      (set! balance (- balance amount))                      balance)                      "Insufficient funds") ) )) (define  a1 ((new-withdraw)30)) (define a2 ((new-withdraw)40)) Now define new-withdraw as a procedure; note the brackets!

  7. Example: new-withdraw Π=9

  8. Example: new-withdraw new-withdraw’ let’ Π=9

  9. Example: new-withdraw new-withdraw’ let’ lambda’ Π=4 Π=9

  10. Example: new-withdraw Π=10

More Related