Teach Yourself Scheme in Fixnum Days [Go to first, previous, next page; contents; index]Chapter 2Data typesA data typeis 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 typesThe simple data types of Scheme include booleans, numbers, characters, and symbols.2.1.1 BooleansScheme's booleans are #tfor true and #ffor false. Scheme has a predicate procedure called boolean?that checks if its argument is boolean.(boolean? #t) =>#t(boolean? "Hello, World!") =>#fThe procedure notnegates its argument, considered as a boolean.(not #f) =>#t(not #t) =>#f(not "Hello, World!") =>#fThe last expression illustrates a Scheme convenience: In a context that requires a boolean, Scheme will treat any value that is not #fas a true value.2.1.2 NumbersScheme 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]
has intentionally blurred sections.
Sign up to view the full version.