;;; Sample Scheme (R7RS) program — samplefiles.com
(import (scheme base) (scheme write))

(define-record-type customer
  (make-customer id name balance)
  customer?
  (id customer-id)
  (name customer-name)
  (balance customer-balance))

(define (vip? c) (>= (customer-balance c) 10000))

(define (total-balance customers)
  (apply + (map customer-balance customers)))

(define customers
  (list (make-customer 1 "Ada" 12500)
        (make-customer 2 "Grace" 830.5)
        (make-customer 3 "Linus" 10000)))

(for-each
 (lambda (c)
   (display (customer-name c))
   (display "\t")
   (display (customer-balance c))
   (display (if (vip? c) "\tVIP" ""))
   (newline))
 customers)
(display "Total: ")
(display (total-balance customers))
(newline)
