1 Welcome to PLT Scheme
2 Scheme Essentials
3 Built-In Datatypes
4 Expressions and Definitions
5 Programmer-Defined Datatypes
6 Modules
7 Input and Output
8 Contracts
9 Classes and Objects
10 Exceptions and Control
11 Iterations and Comprehensions
12 Regular-Expression Matching (Regexps)
13 Pattern Matching
14 Quasiquoting
15 Units (Higher-Order Modules)
16 Threads
17 Syntactic Extension (Macros)
18 Reflection and Dynamic Evaluation
19 Reader Extension
20 Security
21 Memory Management
22 Performance
23 Foreign-Function Interface (FFI)
24 Scripts
25 Graphical User Interfaces (GUIs)
26 More Tools
Index

contents

 index

← prev  up  next →

 

2.1 Simple Values

Scheme values include numbers, booleans, strings, and byte strings. In DrScheme and documentation examples (when you read the documentation in color), value expression are shown in green.

Numbers are written in the usual way, including fractions and imagnary numbers:

Numbers (later in this guide) explains more about numbers.

  1                        1.0

  1/2                      0.5

  9999999999999999999999   1e+22

  1+2i                     1.0+2.0i

Booleans are #t for true and #f for false. In conditionals, however, all non-#f values are treated as true.

Booleans (later in this guide) explains more about booleans.

Strings are written between doublequotes. Within a string, backslash is an escaping character; for example, a backslash followed by a doublequote includes a little doublequote in the string. Except for an unescaped doublequote or backslash, any Unicode character can appear in a string constant.

Strings (Unicode) (later in this guide) explains more about strings.

  "hello world"

  "A \"fancy\" string"

  "λx:(μα.α→α).xx"

When a constant is evaluated in the REPL, it typically prints the same as its input syntax. In some cases, the printed form is a normalized version of the input syntax. In documentation and in DrScheme’s REPL, results are printed in blue instead of green to highlight the difference between an input expression and a printed result.

Examples:

  > 1.0000

  1.0

  > "A \u0022fancy\u0022 string"

  "A \"fancy\" string"

 

contents

 index

← prev  up  next →