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

LISP Atoms and Data Types

A tour of LISP's core data types, numbers, symbols, strings, characters, and booleans, and how lists combine them into compound structures.

FoundationsBeginner8 min readJul 10, 2026
Analogies

LISP Atoms and Data Types

Every value LISP works with is either an atom or built from atoms grouped into a list. The four core atomic types are numbers, symbols, strings, and characters. Numbers represent quantities and support exact arithmetic; symbols are names, most often used as identifiers for variables and functions; strings hold ordered text; characters represent single letters or punctuation marks on their own. Understanding these building blocks is essential before working with the compound list structures built on top of them.

🏏

Cricket analogy: LISP's atomic data types, numbers, symbols, strings, characters, are like the basic categories on a cricket scorecard: runs as numbers, player names as symbols, extras descriptions as strings, and single-letter shot codes as characters, distinct primitive kinds of information the scoreboard is built from.

Numbers, Symbols, and Strings

Common Lisp's numeric tower includes integers, exact ratios such as 1/3, and floating-point numbers, and arithmetic between exact types stays exact rather than silently rounding. Symbols like hello are names, printed in uppercase by default because the standard reader upcases unescaped symbols before storing them internally. Strings hold ordered sequences of characters written between double quotes, such as a filename like 'sunset-beach.jpg', and functions like length and concatenate operate on them directly.

🏏

Cricket analogy: LISP's numeric tower including exact ratios like 1/3 alongside integers and floats is like a scorer recording the exact fractional over, four overs and three balls, rather than rounding to a whole number; precision matters, so the format captures fractions exactly.

lisp
;; Numbers: integers, ratios, and floats are all distinct types
42              ; integer
1/3             ; exact ratio (rational number)
3.14            ; single-float

;; Symbols are names, printed upcased by default
'hello          ; => HELLO
(symbolp 'hello) ; => T

;; Strings are sequences of characters in double quotes
"Hello, LISP!"  ; a string
(length "Hello, LISP!")  ; => 13

Characters and Booleans: T and NIL

A character literal is written with a #\ prefix, so #\A represents the letter A as a standalone value distinct from a one-character string. Common Lisp represents true with the symbol T and false with NIL, and every conditional special form treats any non-NIL value, including 0 and an empty string, as true. NIL does unusually heavy lifting: it is simultaneously the boolean false value, the empty list (), and the symbol that terminates every proper list, so the same token carries three overlapping meanings depending on context.

🏏

Cricket analogy: A LISP character like #\W standing for a single wicket code on a scorecard is like the single-letter shorthand umpires and scorers use to mark a dismissal, one indivisible symbol representing one specific event.

Lists as Compound Data

Lists are built from cons cells, each holding a first element and a pointer to the rest. The cons function prepends a new element onto an existing list, car retrieves the first element of a cons cell, and cdr retrieves everything after it. A chain of cons calls terminating in NIL, such as (cons 1 (cons 2 (cons 3 nil))), is exactly what the literal list (1 2 3) means internally, which is why NIL also serves as the marker for the end of a proper list.

🏏

Cricket analogy: Building a list by prepending an element onto an existing sequence of over totals is like adding the latest ball's runs to the front of an over's running tally: cons prepends a new element onto an existing list, growing it from the front just like updating an over ball by ball.

lisp
;; cons builds a new list by prepending an element
(cons 4 '(6 1 0))     ; => (4 6 1 0)

;; car returns the first element of a list
(car '(4 6 1 0))      ; => 4

;; cdr returns everything except the first element
(cdr '(4 6 1 0))      ; => (6 1 0)

;; Lists are built entirely from cons cells, ending in NIL
(cons 1 (cons 2 (cons 3 nil)))  ; => (1 2 3)

Any value other than NIL, including 0 and an empty string, counts as true, which trips up programmers coming from languages where 0 or an empty collection is falsy. NIL alone means false, the empty list, and the end-of-list marker, all at once.

  • LISP's core atomic types are numbers, symbols, strings, and characters.
  • The numeric tower includes integers, exact ratios (rational numbers like 1/3), and floating-point numbers.
  • Symbols are names used as identifiers and are upcased by the reader by default in standard Common Lisp.
  • Strings are sequences of characters written in double quotes; individual characters use the #\ prefix, e.g. #\A.
  • T represents true and NIL represents both false and the empty list, a deliberate, sometimes confusing overload.
  • Lists are compound data built from cons cells; car retrieves the first element and cdr retrieves the rest.
  • Any non-NIL value, including 0 and empty strings, is treated as true in conditional expressions.

Practice what you learned

Was this page helpful?

Topics covered

#Programming#LISPStudyNotes#LISPAtomsAndDataTypes#LISP#Atoms#Data#Types#StudyNotes#SkillVeris#ExamPrep