Prev Up Next

A Scheme script uses the variable argv to refer to its arguments. For example, the following script echoes all its arguments, each on a line:

":"; exec mzscheme -r $0 "$@"

;Put in argv-count the number of arguments supplied

(define argv-count (vector-length argv))

(let loop ((i 0))
  (unless (>= i argv-count)
    (display (vector-ref argv i))
    (loop (+ i 1))))

Let's call this script echoall. Calling echoall 1 2 3 will display


Note that the script name ("echoall") is not included in the argument vector.

Prev Up Next

Log in or registerto write something here or to contact authors.