# Forms and values

From A Little Lisp for a Small World, the Plazmi Lisp book (https://plazmi.gg/book). Checked against Plazmi Lisp version 2, 12 November 2026. The whole book as one file: https://plazmi.gg/book.md

Everything you write in Plazmi Lisp is a form. A form is either a value, like `3` or `"Ting."`, or a list in parentheses that works a value out, like `(+ 1 2)`. This chapter is about both.

## Values answer themselves

A value is the simplest form. Send one, and it answers itself:

```clojure
42
2.5
-7
"Ting."
true
false
nil
:rain
```

```text
42
2.5
-7
"Ting."
true
false
nil
:rain
```

A plan can hold several forms, one after another, and each answers in turn. Here are the kinds of plain value:

- **Numbers**: whole numbers like `42` and `-7`, and decimals like `2.5`.
- **Text** in double quotes: `"Ting."`. Text can hold any characters, quote marks too, written `\"` inside.
- **`true` and `false`.**
- **`nil`**, which means nothing: no value at all.
- **Keywords**, which start with a colon: `:rain`, `:rings`, `:front`. A keyword is a name used as a value. You will use them for the keys of maps and for choices like which side of the house.

## Values that hold values

Four kinds of value hold other values:

```clojure
[1 2 3]
{:rings 0 :colour "rose"}
#{"basil" "mint"}
#"[a-z]+"
```

```text
[1 2 3]
{:rings 0, :colour "rose"}
#{"mint" "basil"}
#"[a-z]+"
```

- A **list** in square brackets, `[1 2 3]`, holds values in order. (Lisp calls this a vector; this book calls it a list, as the language's table does.)
- A **map** in braces, `{:rings 0 :colour "rose"}`, holds keys and their values, in pairs. When Plazmi prints a map it puts a comma between the pairs; you can leave the commas out, and the book does.
- A **set**, `#{"basil" "mint"}`, holds values with no order and no repeats. It prints them in an order of its own, as here.
- A **pattern**, `#"[a-z]+"`, describes text to look for. Chapter 3 uses them.

Lists, maps and sets can hold any values, other lists and maps among them: `{:guests ["@mira" "@cairn"] :open true}` is a map whose `:guests` is a list of text.

## Lists that work something out

A list in parentheses is a call. Its first word says what to do, and the rest are what that word takes:

```clojure
(+ 1 2 3)
(* 6 7)
(- 10 4)
(max 3 9 4)
(str "Hello, " "Mira")
```

```text
6
42
6
9
"Hello, Mira"
```

`+` adds every number it is given. `str` joins its values into one text. The word always comes first, so there is never any question of which comes before which: `(+ 1 2 3)` is the whole sum.

## Inside out

Calls go inside calls. Plazmi works out the innermost first, and passes each answer outwards:

```clojure
(+ (* 2 3) (* 4 5))
(str "That's " (+ 1 2) " rings.")
```

```text
26
"That's 3 rings."
```

Read `(+ (* 2 3) (* 4 5))` from the inside: `(* 2 3)` is 6, `(* 4 5)` is 20, and `(+ 6 20)` is 26. That is the whole grammar of the language. Everything else is which words there are.

## What kind of value

`type` says what kind a value is, in a word:

```clojure
(type 3)
(type 2.5)
(type "three")
(type :three)
(type [3])
(type {:n 3})
(type nil)
```

```text
:number
:number
:text
:keyword
:vector
:map
:nil
```

## A list as data

Sometimes you want a list in parentheses as a value, not a call. A quote mark in front stops it being called:

```clojure
'(1 2 3)
```

```text
(1 2 3)
```

You will rarely need this: square brackets are the usual way to write a list.

## Notes to yourself

A semicolon starts a note that runs to the end of the line. Plazmi reads past it:

```clojure
;; how many legs on three stools
(* 3 3) ; three each
```

```text
9
```

Notes are for whoever reads the plan as you sent it. When Plazmi keeps a toy, it keeps the Lisp, not the notes (chapter 16).

## A word that isn't one

Every word that starts a list is checked against the language's table before anything runs. A word the table hasn't got stops the whole plan, and the reply names it, with the nearest words that are:

```clojure
(print "hello")
```

```text
That plan uses print, which isn't one of its words, so nothing in it ran. Nearest: …
```

Nothing ran, and nothing changed. Plazmi has no printing: a form answers its value instead, as every example in this chapter did.

## Try it

1. Send a plan that answers the number of hours in a week, worked out with `*`.
2. Write one form that answers the text `"3 bells, 2 chimes"`, using `str` and two sums.
3. What does `(type (str 1 2))` answer? Work it out, then send it.
4. Write a map for a toy that has rung 4 times and is called "Bell".

## Recap

- A form is a value or a list. A value answers itself; a list calls its first word on the rest.
- Values: numbers, text, `true`, `false`, `nil`, keywords, lists `[…]`, maps `{…}`, sets `#{…}` and patterns `#"…"`.
- Calls nest, and are worked out from the inside.
- A word not in the table stops the plan before anything runs, and the reply names it.

Next, names: how to give a value a name and use it.


---

Before: [Preface](https://plazmi.gg/book/preface.md). Next: [Names](https://plazmi.gg/book/names.md). Contents: https://plazmi.gg/book.md
