100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Scheme Cheat Sheet

Scheme Cheat Sheet

Foundational Scheme syntax including define, let forms, list operations, and recursion for this minimalist Lisp dialect.

1 PageBeginnerMar 28, 2026

Basic Syntax & Definitions

Defining values, functions, and conditionals.

scheme
(define x 10)(define (square x) (* x x))(define square (lambda (x) (* x x)))  ; equivalent form(if (> x 0) 'positive 'negative)(cond ((> x 0) 'positive)      ((< x 0) 'negative)      (else 'zero))

Let Forms

Local bindings with let, let*, and named let.

scheme
(let ((a 1) (b 2))  (+ a b))                ; bindings evaluated in parallel(let* ((a 1) (b (+ a 1)))  (+ a b))                ; sequential, b can see a(let loop ((i 1) (acc 0))  ; named let for iteration  (if (> i 5)      acc      (loop (+ i 1) (+ acc i))))

List Operations

Core procedures for working with pairs and lists.

  • (car lst)- returns the first element of a pair/list
  • (cdr lst)- returns the rest of the list after the first element
  • (cons a b)- constructs a new pair with a as car and b as cdr
  • (list a b c)- builds a proper list from its arguments
  • (null? lst)- true if lst is the empty list '()
  • (length lst)- returns the number of elements in a proper list
  • (append lst1 lst2)- concatenates two lists into one
  • (map proc lst)- applies proc to each element, returns a new list

Recursion

Scheme relies on recursion instead of traditional loops.

scheme
(define (factorial n)  (if (= n 0)      1      (* n (factorial (- n 1)))))(factorial 5)  ; => 120(define (sum-to n)  (let loop ((i 1) (acc 0))    (if (> i n)        acc        (loop (+ i 1) (+ acc i)))))(sum-to 100)   ; => 5050, tail-recursive so it runs in constant space
Pro Tip

Write recursive functions in tail-call form (like the named-let loop above) — conforming Scheme implementations guarantee proper tail-call optimization, so tail recursion runs in constant stack space just like a loop.

Was this cheat sheet helpful?

Explore Topics

#Scheme#SchemeCheatSheet#Programming#Beginner#BasicSyntaxDefinitions#LetForms#ListOperations#Recursion#DataStructures#Algorithms#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet