[英]“and” and tail recursion
Can I build iterative process using recursive call in and
statement? 我可以使用递归调用in
and
语句构建迭代过程吗?
For example, purpose, we have function foo
that doesn't do anything. 例如,目的,我们有没有做任何事情的函数
foo
。 What kind of process it will create (iterative or recursion)? 它将创建什么样的过程(迭代或递归)?
(define (foo? bar)
(if (< bar 0) true (and (> 10 1) (foo? (- bar 1)))))
是的, and
是OK -你可以在阅读本标准 。
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.