let clauses

A let clause binds a variable to the entire result of an expression. A let clause does not perform any iteration.

The simplest type of let clause contains one variable and an associated expression. In the following example, the let clause includes a variable called $j and an expression that constructs the sequence (1, 2, 3).
let $j := (1, 2, 3)
return <output>{$j}</output>
When the let clause is evaluated, a single binding is created for the entire sequence that results from evaluating the expression:
$j = 1 2 3
The return clause in the example executes once. The expression results in the following output:
<output>1 2 3</output>
A let clause can contain multiple variables. However, unlike a for clause, a let clause binds each variable to the result of its associated expression, without iteration. In the following example, a let clause contains two variables, $a and $b, and expressions that construct the sequences 1 2 and 4 5:
let $a := (1, 2), $b := (4, 5)
return <output>{$a, $b}</output>
When the let clause is evaluated, one tuple of variable bindings is created:
($a = 1 2, $b = 4 5)
The return clause in the example executes once for the tuple. The expression results in the following output:
<output>1 2 4 5</output>

When the binding expression evaluates to an empty sequence, a let binding is created, which contains the empty sequence.