Racket Basic Data Types

Numbers

Any kind of number. Racket makes no distinction between integers, real numbers, rationals, etc. Literal representations match what you are used to from math and from other programming languages.

Operations Description
number? type predicate - returns true if argument is a number
zero? test if argument is zero
=, <, <=, >, >= comparison operators
+, -, *, /, etc. standard arithmetic operations

Booleans

Two possible values: #t for true and #f for false.

Operations Description
boolean? type predicate
eq? equality test
and, or, not standard boolean operators

Symbols

An identifier that is used as a value. We must "quote" the identifier so the interpreter knows not to evaluate the identifier. This is done either as (quote blue) or 'blue.

Operations Description
symbol? type predicate
eq? equality test
and, or, not standard boolean operators

Characters

For printable literals: precede with a #\. For example, #\a is the character 'a'.

For nonprintable literals: use the character's name preceded by #\. For example, #\space and #\newline are the space and newline characters.

Operations Description
char? type predicate
char-alphabetic?, char-numeric?, char-whitespace? determine the type of the character
char=?, char<?, char<=?, char>?, char>=? comparison operators
char->integer return the ASCII value of a character

Strings

A sequence of characters surrounded by double quotes ("").

Operations Description
string? type predicate
string=?, string<?, string<=?, string>?, string>=? comparison operators
string-ci=?, string-ci<?, string-ci<=?, string-ci>?, string-ci>=? case-insensitive comparison operators
string-length return length of a string/td>
string-ref returns the character at given index:
(string-ref "Eugene" 0)
string-append concatenate two strings to create a new string
string->list, string->symbol, string->number convert a string to another type
string create a string from zero or more characters