Skip to content

Looping Exercise

  • Write a function similar to triangle in which each row has a value which is the square of the row number. Use a while loop.

  • Write a function similar to triangle that multiplies instead of adds the values.

  • Rewrite these two functions recursively. Rewrite these functions using cond.

  • Write a function for Texinfo mode that creates an index entry at the beginning of a paragraph for every ‘@dfn’ within the paragraph. (In a Texinfo file, ‘@dfn’ marks a definition. This book is written in Texinfo.)

    Many of the functions you will need are described in two of the previous chapters, Cutting and Storing Text, and Yanking Text Back. If you use forward-paragraph to put the index entry at the beginning of the paragraph, you will have to use C-h f (describe-function) to find out how to make the command go backwards.

    For more information, see Indicating in Texinfo Manual, which goes to a Texinfo manual in the current directory. Or, if you are on the Internet, see https://www.gnu.org/software/texinfo/manual/texinfo/