This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
I don't know how Hobbit-friendly is the following, but it seems to work. Note that the macro is called `and-let*', as Jim suggested. (I like it much better than `land*' too, BTW). (define-module (and-let*)) (defmacro and-let* (vars . body) (define (expand vars body) (cond ((null? vars) `(begin ,@body)) ((pair? vars) (let ((exp (car vars))) (cond ((pair? exp) (cond ((null? (cdr exp)) `(and ,(car exp) ,(expand (cdr vars) body))) (else (let ((var (car exp)) (val (cadr exp))) `(let (,exp) (and ,var ,(expand (cdr vars) body))))))) (else `(and ,exp ,(expand (cdr vars) body)))))) (else (error "not a proper list" vars)))) (expand vars body)) (export-syntax and-let*)