First Program

Run a program, change its result from 5 to 10, and fix a missing parenthesis. Then run the same file on your computer.

Your first program collects a symbol, a string, and a sum into one list. You run it in the browser with no installation, change the sum, and repair a missing parenthesis.

Run it in the Playground

Open the Playground, replace the editor contents with this program, and choose Run.

LISPEX
(define language "Lispex")

(list 'hello language (+ 2 3))

Result

OUTPUT
(hello "Lispex" 5)

define gives the string "Lispex" the name language. The final expression calls list to collect three values. They are the symbol hello, the string stored as language, and the sum of 2 and 3. The quote before hello keeps that name as data.

The Playground shows the values of expressions written at the outermost level of the program. define itself produces no displayed value.

Change 3 to 8 and run again.

Result

OUTPUT
(hello "Lispex" 10)

The last item changes because (+ 2 8) returns 10. The symbol and string stay the same.

Fix a missing parenthesis

Replace the editor contents with this example. Its first line is missing a closing parenthesis.

LISPEX
(define total 10

(+ total 5)

Lispex reports error E100. It cannot finish reading the first expression, so it runs none of the program. Add ) after 10 and run again.

Result

OUTPUT
15

The corrected program defines total as 10, then adds 5. See Error and Warning Codes for errors during reading, syntax expansion, execution, or resource use.

Exercise

Return to the first program and change it to produce this result.

(hello "Lispex" 12)
Show one answer

Change the final expression to (list 'hello language (* 3 4)). Lispex calculates (* 3 4) before list receives its three values.

Run it on your computer

Install Native or npm from Downloads. Then save the original program as hello.lspx.

LISPEX
(define language "Lispex")

(list 'hello language (+ 2 3))

With the npm package installed in your project, run the file with npx.

SHELL
npx lispex hello.lspx

With Native, run the same file with lispex.

SHELL
lispex hello.lspx

Both commands print this result, exit with status 0, and create no files.

(hello "Lispex" 5)

Save the program with the missing parenthesis as unfinished.lspx.

LISPEX
(define total 10

(+ total 5)

Run it with Native.

SHELL
lispex unfinished.lspx

The command exits with status 1 and writes this diagnostic to standard error.

E100 unfinished.lspx:1:1 unterminated list (missing `)`)

To compare the Playground, npm, and Native, see Choose where to run on Downloads.

To call a rule from your own application, read Run Lispex in Your Application.

The editor extension on Downloads adds syntax highlighting and formatting.

Continue to the Learning Path

When you can explain the name, string, nested call, and final list, continue to the Learning Path. It lists the lessons that lead to your first decision rule.