# Loops

DSSSL doesn't have any construct that resembles the for loop that occurs in most imperative languages like C and Java. Instead, DSSSL employs a common trick in functional languages for implementing a loop: tail recursion.

for loop, DSSSL and
loops, implementing (DSSSL)
tail recursion (DSSSL)

Loops in DSSSL use a special form of `let`. This loop counts from 1 to 10:

    (let loopvar ((count 1))
      (if (> count 10)
        #t
        (loopvar (+ count 1))))

This variable controls the loop. It is declared without an initial value, immediately after the `let` operand.

Any number of additional local variables can be defined after the loop variable, just as they can in any other `let` expression.

variables (DSSSL) local, defining after loop variable

If you ever want the loop to end, you have to put some sort of a test in it.

This is the value that will be returned.

Note that you iterate the loop by using the loop variable as if it was a function name.

The arguments to this function are the values that you want the local variables declared in to have in the next iteration.