"and" and tail recursion
Can I build iterative process using recursive call in and
statement?
For example, purpose, we have function fo开发者_JAVA技巧o
that doesn't do anything. What kind of process it will create (iterative or recursion)?
(define (foo? bar)
(if (< bar 0) true (and (> 10 1) (foo? (- bar 1)))))
Yes, and
is OK - you can read this in the standard.
For Lamberts sake, lets expand the syntax.
(define (foo? bar)
(if (< bar 0)
#t ; tail position, but no call
(if (> 10 1)
(foo? (- bar 1)) ; tail position
#f))) ; tail position, but no call
精彩评论