[xquery-talk] exiting the for

Martin Probst martin at x-hive.com
Wed Mar 1 17:55:35 PST 2006


> Hello, is there any way to exit from the for clause  before reaching the end of the binding sequence?

The "for-loop" is not actually a loop, so there is no way of exiting it
- in functional languages you don't have that kind of flow control.

However optimising XQuery implementations will probably not evaluate the
whole loop if you just use parts of the result, e.g.:
> subsequence(for $i in 1 to 1000
>             return $i,
>             1,
>             10)
will only evaluate the first 10 elements of the sequence from the for
loop as the others are not needed for the result of the "subsequence"
call.

Martin



More information about the talk mailing list