SRFI 2 provides a form that combines `and' and `let*' for a logically short-circuiting sequential binding operator.
Runs through each of the clauses left-to-right, short-circuiting like `and' in that the first false clause will result in the whole `and-let*' form returning false. If a body is supplied, and all of the clauses evaluate true, then the body is evaluated sequentially as if in a `begin' form, and the value of the `and-let*' expression is the value of the last body form, evaluated in a tail position with respect to the `and-let*' expression. If no body is supplied, the value of the last clause, also evaluated in a tail position with respect to the `and-let*' expression, is used instead.
Each clause should have one of the following forms:
- in which case identifier's value is tested.
- in which case the value of expression is tested.
- `(identifier expression)'
- in which case expression is evaluated, and, if its value is not false, identifier is bound to that value for the remainder of the clauses and the optional body.
(and-let* ((list (compute-list)) ((pair? list)) (item (car list)) ((integer? item))) (sqrt item))