Data Types: The Shapes of Thought

Numbers, strings, lists, booleans... these are not just data, but different vessels for containing thought. Discover the forms that data takes in Lispex and how these shapes model the world.

This page introduces the everyday data found on Lispex v1’s input‑only S‑expression surface. Execution semantics and libraries are out of scope. The snippets below work in the LENA code transformer.

Tip: open LENA code in a new tab and try snippets: www.lenacode.com

Primitive Types

The fundamental values that appear in Lispex.

Numbers

Integers, rationals, and reals (input forms):

30
19.99
-100
42/7          ; rational input form

Booleans

Truth values are #t and #f.

#t
#f
(and #t #t)       ; ⇒ #t
(or #f #t)        ; ⇒ #t
(not #t)          ; ⇒ #f
(if #t "yes" "no") ; ⇒ "yes"

Characters

Single character values.

#\a
#\space
#\x03B1          ; Greek alpha

Strings

Represents sequences of characters, enclosed in double quotes.

"Lispex Language"
"Hello, Lispex! 👋"
""
"quote: \" \n tab: \t hex: \x41;" ; escapes

Collection Types

Lists

Ordered collections of items. Create with (list ...). The empty list literal is (). Dotted lists are allowed as input.

(list)                          ; empty
(list 1 2 3 4 5)
(list "hello" "world" "lispex")
(list 1 (list 2 3) 4)          ; nested
(1 2 3 . 4)                     ; dotted list input

Common operations live in the standard library (first/rest/length, append, map/filter, …).

Vectors

#(1 2 3)
#("a" "b" "c")

Bytevectors

Arrays of bytes (integers 0–255).

#u8(72 101 108 108 111)

In R5RS‑compat mode, #u8(...) may be automatically replaced with a plain vector (with a warning). See notes below.

Quote family

Reader shorthands to build data.

'x               ; ⇒ (quote x)
`(a ,x ,@ys b)   ; ⇒ (append (list 'a x) ys (list 'b))

Functions

Functions are first‑class. Define with lambda, or with definition sugar:

(define (add a b) (+ a b))
(add 10 20) ; ⇒ 30
(lambda (n) (+ n 1)) ; anonymous function value

R5RS‑compat notes

Enable the toggle at the top of a file:

;! compat: r5rs
  • Bytevectors #u8(...) may be replaced by plain vectors.
  • case matching is described with equal? here but R5RS evaluators use eqv?.
  • Surface module headers (module ...) are dropped/flattened at top level.