How to Read program arguments in Lisp

Lisp is a completely different way of looking at programming than e.g. ruby is. Where in Ruby everything is an object - in lisp everything is a list. Which makes sense, since lisp is an acronym for LISt Processing.

To get program arguments in lisp is not something uniform - each lisp dialect has it’s own way of doing it. For an example covering if not all, then many of the dialects, see this listing at

The code below is for the dialect called clisp.

First we define a variable counter, and initialize it to zero.

Then we loop through all the elements (e) in the program arguments (args). The collect call runs the “callback”. This is made a list of commands with progn instead of just a single command. This lets us increment the counter, before concating all the string elements into a final string, which is then printed to stdout.