Your first program¶
In this tutorial you will write a small expense report and run it as a script.
You need a working egcl command on your PATH; if you do not have one,
build and install it first.
Evaluate an expression¶
In a terminal, run:
EGCL prints 25 and exits.
Define a function in the REPL¶
Start the interactive read–eval–print loop:
At the CL-USER> prompt, enter:
The function definition returns its name. The next expression returns 25.
You can call the function with another list without redefining it:
This returns 10. Enter (quit) to leave the REPL.
Put the program in a file¶
Create expenses.lisp with this content:
(defun total (amounts)
(reduce #'+ amounts :initial-value 0))
(format t "~A: ~D~%"
(first *command-line-args*)
(total '(12 8 5)))
Run the file, passing a report label after --:
The program prints:
You now have a Lisp script that takes input from the command line and produces formatted output. To distribute an executable containing your loaded program, continue with Save an executable.