问题如下。我们需要给予程序如阶乘函数的定义以语义function factorial(n:Nat):Nat ≡ if (n==0)then 1 else n*factorial(n-1)。这个阶乘程序的意义应当是在自然数上一个函数,但是由于它的递归定义,如何以复合方式理解它是不明白的。
每一个递归程序都遵循相同的基本步骤。
Every recursive program follows the same basic sequence of steps.
答案就是它使用一个递归程序。
有时候,编写递归程序时难以获得更简单的子问题。
Sometimes when writing recursive programs, finding the simpler sub-problem can be tricky.
The last point I want to make to you is, you've started writing programs that you would think of as being inherently iterative.
能反映递归特性的程序,我最后一点想说的是,你已经开始编写你认为。
应用推荐