Code · 1 file

Sample Scheme File

R7RS Scheme with a record type. Every language sample implements the same small program so you can compare them side by side.

Scheme · 747 B

Sample Scheme file

An idiomatic Scheme example — the same customer program (or, for hardware languages, a small counter design) we offer in every language.

CC0 · free for any use · Verified by an independent tool · Report a problem

sample.scm — first linesScheme
;;; 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))

File details

Size
747 B (747 bytes)
MIME type
text/x-scheme
SHA-256
97ee1c392582c389796a381eb8b3480e3a627b813aa3a8c10f758bd18dc7fcd4
MD5
a05d6940ee741b47174400b5908e3763

Download from the command line

curl -L -o sample.scm https://files.samplefiles.com/code/scm/sample.scm

Or check the download in your browser with the checksum calculator.