Catalog / Racket Programming Cheatsheet
Racket Programming Cheatsheet
A concise reference for Racket programming, covering syntax, data structures, control flow, and module system basics.
Racket Basics & Syntax
Core Syntax
Expressions |
Racket code consists of expressions. Expressions can be literals, identifiers, or procedure applications. |
Procedure Application |
|
Defining Variables |
|
Comments |
|
Boolean Values |
|
Number Types |
Racket supports integers, rational numbers, real numbers, and complex numbers. |
Basic Data Types
Numbers: Integers, decimals, fractions. Booleans: Strings: Enclosed in double quotes, e.g., Symbols: Quoted identifiers, e.g., |
Lists: Ordered collections, e.g., |
Vectors: Fixed-size arrays, e.g., |
Common Procedures
|
Addition. |
|
Subtraction. |
|
Multiplication. |
|
Division. |
|
Numerical equality. |
|
Less than. |
Control Flow
Conditionals
|
|
Boolean Logic
|
Returns |
|
Returns |
|
Returns |
Iteration
|
|
(let loop ([var1 init1] [var2 init2] …) body) |
Data Structures
Lists
|
Creates a new list containing the given arguments. |
|
Constructs a new list by adding |
|
Returns the first element of |
|
Returns the rest of |
|
Returns |
|
Returns the number of elements in |
Vectors
|
Creates a new vector containing the given arguments. |
|
Returns the element at |
|
Sets the element at |
|
Returns the number of elements in |
|
Returns |
Hash Tables
|
Creates a new empty hash table. |
|
Associates |
|
Returns the value associated with |
|
Returns the value associated with |
|
Removes the association for |
Modules
Module Definition
|
|
Exports
|
|
Imports
|
|
|