Values in Scheme
Our first example will demonstrate various value types in Scheme, including strings, numbers, and booleans. Here’s the code:
To run this program, save it to a file (e.g., values.scm
) and use your Scheme interpreter. For example, if you’re using Guile:
Let’s break down the example:
Strings in Scheme are delimited by double quotes. We use
string-append
to concatenate strings.Numbers in Scheme can be integers or floating-point. Arithmetic operations like addition (
+
) and division (/
) are performed using prefix notation.Booleans in Scheme are represented as
#t
for true and#f
for false. The logical operatorsand
,or
, andnot
work as expected.We use
display
to print values andnewline
to print a new line character.
This example demonstrates basic value types and operations in Scheme. As you can see, Scheme uses prefix notation for all operations, which is a characteristic of Lisp-like languages.