如何设计While循环
How to Design While Loops
摘要:
初学者发现被称为while循环的句法结构很难掌握。困难围绕着保证循环终止和学习如何正确地排序突变来解决问题。事实上,这两者是交织在一起的,学生需要学习一个模型,帮助他们推理如何设计while循环。对于已经介绍了如何使用结构递归,生成递归,累积递归和突变设计程序的学生,教他们如何设计while循环的任务变得更容易。例如,这些学生熟悉状态变量、终止参数和累加器不变量。所有这些都是while循环设计的基础。本文介绍了Seton Hall大学使用的一种新技术,向初学者介绍while循环的设计。它提出了一个设计食谱,学生可以按照一步一步地建立这样的事情,如循环的驱动程序,循环不变,和正确的突变序列。本文还提供了一个使用新设计配方设计基于while循环的函数的示例。
英文摘要:
Beginning students find the syntactic construct known as a while loop difficult to master. The difficulties revolve around guaranteeing loop termination and around learning how to properly sequence mutations to solve a problem. In fact, both of these are intertwined and students need to be taught a model that helps them reason about how to design while loops. For students that have been introduced to how to design programs using structural recursion, generative recursion, accumulative recursion, and mutation, the task of teaching them how to design while loops is made easier. These students are familiar, for example, with state variables, termination arguments, and accumulator invariants. All of these are fundamental in the design of while loops. This articles presents a novel technique used at Seton Hall University to introduce beginners to the design of while loops. It presents a design recipe that students can follow step-by-step to establish such things as the driver of the loop, the loop invariant, and the proper sequencing of mutations. The article also presents an example of designing a while-loop based function using the new design recipe.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。