Lecture 10 Notes

Variant name general form of this

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ¡ §    !¢ "¡  6§ "¡ ¥ ¤¢ ©© ¡§   § !¢ ©¢  £ "¡ ¥  £  § ¥  ¨¥  § fact-iter usage: produces: Compare this behavior with that of the following procedures. In keeping with our preceding slogan (“No Mysterious Auxiliaries!”), notice that has its own purpose statement: it calculates n! a. This is easy to check, and also justifies the initial call from to . It also makes a generalization of , just as was a generalization of . ¦§ ¡ 5¤¢¡ ¤©1 § 4¡ "¡4  "¡ ¥    ¤© ©¢  £    § ¡ 5!¡ ¤¡ 1 § 4¡ " 4   ¢£  "¡ ¥  ¤¢ ©¢  ¢£      ¢¤¢ ©©  £ "¡ ¥  4 D" !¨¥  ¤¢  ¤ £¦§ "    ¤¢ ©¢  ¢£ "¡ ¥  But we digress. . . .    !¢ ©¢  £ "¡ ¥    !¢ ©¢  £ "¡ ¥     !¢ ©¢  £ "¡ ¥  Here, is always invoked in the same context (in this case, no context at all). When calls itself, it does so at the “tail end” of a call to . That is, no promise is made to do anything with the returned value other than return it as the result of the call to . This is called tail recursion.    !¢ ©¢  £ "¡...
View Full Document

Ask a homework question - tutors are online