{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Chapter 2 - Teach Yourself Scheme in Fixnum Days[Go to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Teach Yourself Scheme in Fixnum Days [Go to first , previous , next page; contents ; index ] Chapter 2 Data types A data type is a collection of related values. These collections need not be disjoint, and they are often hierarchical. Scheme has a rich set of data types: some are simple (indivisible) data types and others are compound data types made by combining other data types. 2.1 Simple data types The simple data types of Scheme include booleans, numbers, characters, and symbols. 2.1.1 Booleans Scheme's booleans are #t for true and #f for false. Scheme has a predicate procedure called boolean? that checks if its argument is boolean. (boolean? #t) => #t (boolean? "Hello, World!") => #f The procedure not negates its argument, considered as a boolean. (not #f) => #t (not #t) => #f (not "Hello, World!") => #f The last expression illustrates a Scheme convenience: In a context that requires a boolean, Scheme will treat any value that is not #f as a true value. 2.1.2 Numbers Scheme numbers can be integers (eg, 42 ), rationals ( 22/7 ), reals ( 3.1416 ), or complex ( 2+3i ). An integer is a rational is a real is a complex number is a number. Predicates exist for testing the various kinds of numberness: file:///C|/Documents%20and%20Settings/Linda%20Graue...tes/Teach%20Yourself%20Scheme/t-y-scheme-Z-H-4.html (1 of 12) [2/6/2008 11:38:43 AM]
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon