Content from Why Learn Scheme


Last updated on 2025-07-05 | Edit this page

Estimated time: 12 minutes

Overview

Questions

  • Why learn Scheme?

Objectives

  • Understand how Scheme relates to other programming languages
  • Know about some Scheme implementations

Introduction


What you need to know is that there are three sections required for a valid Carpentries lesson template:

  1. questions are displayed at the beginning of the episode to prime the learner for the content.
  2. objectives are the learning objectives for an episode displayed with the questions.
  3. keypoints are displayed at the end of the episode to reinforce the objectives.

Inline instructor notes can help inform instructors of timing challenges associated with the lessons. They appear in the “Instructor View”

Challenge

Challenge 1: Can you do it?

What is the output of this command?

SCHEME

(display "Hello World!\n")

OUTPUT

Hello World!
Challenge

Challenge 2: how do you nest solutions within challenge blocks?

You can add a line with at least three colons and a solution tag.

Callout

Callout sections can highlight information.

They are sometimes used to emphasise particularly important points but are also used in some lessons to present “asides”: content that is not central to the narrative of the lesson, e.g. by providing the answer to a commonly-asked question.

Key Points
  • Scheme is a part of the Lisp family of programming languages
  • There are several implementations of Scheme, choose one appropriate for your needs

Content from Variables and Procedures


Last updated on 2025-07-05 | Edit this page

Estimated time: 12 minutes

Overview

Questions

  • How do you use variables and procedures in Scheme?

Objectives

  • Explore differences between Gambit Scheme and Guile Scheme

Introduction


An alternative implementation of the exercies in variables and procedres section of the Spritely Scheme Primer ported to Gambit Scheme.

SCHEME

(define (chatty-add chatty-name . nums)                                                   
     (string-append chatty-name ", If you add these together you get " (number->string (apply + nums)) "!\n"))

SCHEME

(define (shopkeeper thing-to-buy    
           #!optional (how-many 1)
           (cost 20)
           #!key (shopkeeper "Sammy")
           (store "Plentiful Great Produce"))
           (display
            (string-append "You walk into "
                           store
                           ", grab something from the shelves,\n"
                           "and walk up to the counter.\n\n"
                           shopkeeper
                           " looks at you and says "
                           "'"
                           (number->string how-many)
                           " "
                           thing-to-buy
                           ", eh? That will be "
                           (number->string (* cost how-many))
                           " coins!'\n")))

SCHEME

(shopkeeper "apples")

OUTPUT

You walk into Plentiful Great Produce, grab something from the shelves,
and walk up to the counter.

Sammy looks at you and says '1 apples, eh? That will be 20 coins!'

SCHEME

(shopkeeper "bananas" 10 28)

OUTPUT

You walk into Plentiful Great Produce, grab something from the shelves,
and walk up to the counter.

Sammy looks at you and says '10 bananas, eh? That will be 280 coins!'

SCHEME

(shopkeeper "screws" 3 2
               shopkeeper: "Horace"
               store: "Horace's Hardware")

OUTPUT

You walk into Horace's Hardware, grab something from the shelves,
and walk up to the counter.

Horace looks at you and says '3 screws, eh? That will be 6 coins!'

Need newer version of interpreter for let-values # https://stackoverflow.com/questions/77866133/how-to-use-let-values-in-gambit-scheme

Key Points
  • Scheme implementations may differ in exact functionality offered

Content from Conditionals and Predicates


Last updated on 2025-07-05 | Edit this page

Estimated time: 12 minutes

Overview

Questions

  • How do you control how your program executes?

Objectives

  • Explain how to check whether something is true or false

Introduction


Key Points
  • Program flow can be controlled by evaluating statements and checking conditions