El siguiente programa trata de los diferentes usos de los que hemos hablado sobre el bucle while.
Here's a program that covers the different uses of the while loop that we just talked about.
Esto nos lleva a la siguiente plantilla para la versión con el bucle while de esta función
This leads us to the following template for the while loop version of this function
Algunas veces estos son mas rápidos de escribir que el bucle while equivalente.
Sometimes these are quicker to write than the equivalent while loop.
Pero no hay una condición para detener el bucle while.
Todo excepto el bucle while interno toma tiempo constante,
Everything but the internal while loop takes there constant time.
En otras palabras, el bucle while se ejecuta una vez cumplidas todas las condiciones necesarias para su ejecución.
Simply put, the while loop is executed while all necessary conditions for its execution are met...
Finalmente, sabemos que el bucle while debería detenerse cuando no halla guijarros en una fila.
Finally, we know that the while loop should stop making repeated additions when there are no pebbles in a row.
Después de declarar y asignar las variables internas, podemos comenzar el bucle while.
After the internal variables are declared and bound to their initial values, we can begin the while loop.
Así que la prueba en el bucle while es simple
So the test for the while loop is simply
Y cuando lo encuentre, el bucle while termina, y puedo imprimir el resultado.
When I find it, I terminate the while loop, and I print the result.
Para prevenir que el bucle while se ejecute para siempre, es necesario proporcionar algún mecanismo para vaciar la lista.
To prevent the while loop from running forever, some mechanism needs to be provided to empty the list eventually.
Sabemos que el bucle while implementará continuamente
We know that the while loop will continuously implement
Lo que ocurre es que la prueba-verdadero-o-falso en el bucle while es verdadera, por lo que se ejecuta la expresión de búsqueda.
What happens is that the true-or-false-test in the while loop tests true, so the search expression is executed.