Up: Echo2   [Index]


1.2.2.1 CL Echo2

In this implementation, a do*-loop is used, and no body is actually needed, because all of the processing occurs in the variable lists. It is similar to a range function because multiple variables are possible, and the function iterates over a list. On the first iteration, each of the variables is established with an initial value. arg is made to be the list of command-line arguments, sep is initially the empty string, and s is initially the empty string also. On the next loop, arg is made to be the list of all but the first element, sep is made to be the single space string, and s splices together the string so far, the current string, s, and the first element of arg.

exec ccl --eval '
  (do* ((arg *unprocessed-command-line-arguments* (cdr arg)) (sep "" " ") (s (car arg) (concatenate (quote string) s sep (car arg))))
      ((= (length arg) 1) (pprint s)))' \
  --eval '(quit)' \
  -- "$@"

Listing 1.9: cl/ch1/echo2