Lambda Forever!

Racket's Basic Data Types


CS 3540

Programming Languages
and Paradigms


Number

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


Boolean

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



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


Characters

For printable literals -- precede with a #\ (for example, #\a).

For nonprintable literals -- use special name preceded by #\ (for example, #\space and #\newline).



Operations Description
char? type predicate
char-alphabetic?, char-numeric?, char-whitespace? determine the subtype of the character
char=?, char<?, char>?,
char<=?, char>=
comparison operators
char->integer conversion from character to ASCII value


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>=? comparison operators (case insensitive)
string-length returns length of argument
string-ref returns character at given index
string-append concatenation
string->symbol, string->number, string->list conversion to symbol, number, and list, respectfully
string creates a string from a sequence of characters


Symbol

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 predicate


Eugene Wallingford ..... wallingf@cs.uni.edu ..... January 8, 2018