;; Die ersten drei Zeilen dieser Datei wurden von DrRacket eingefügt. Sie enthalten Metadaten ;; über die Sprachebene dieser Datei in einer Form, die DrRacket verarbeiten kann. #reader(lib "DMdA-assignments-reader.ss" "deinprogramm")((modname account) (read-case-sensitive #f) (teachpacks ()) (deinprogramm-settings #(#f write repeating-decimal #t #t none explicit #f ()))) #;(: balance natural) #;(define balance 130) (: withdraw (natural -> natural)) #;(define withdraw (lambda (amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) (violation "No money!")))) ; Abheben mit lokalen Kontostand (define withdraw (letrec ((balance 130)) (lambda (amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) (violation "No money!"))))) ; Generiere für jeden Kontostand einen Prozessor zum Abheben (: make-withdraw (natural -> (natural -> natural))) (define make-withdraw (lambda (balance) (lambda (amount) (if (>= balance amount) (begin (set! balance (- balance amount)) balance) (violation "No money!"))))) (: A1 (natural -> natural)) (define A1 (make-withdraw 130)) (: A2 (natural -> natural)) (define A2 (make-withdraw 130))