Overview Module Function Class Tea 3.2.5 Reference Documentation
© 2009 PDM&FC

Function while

while condition body

Executes a block of code repeatedly while a condition evaluates to the true boolean value.

Parameters:
condition - A boolean value or a block whose execution results in a boolean value.
body - The block of code that will be repeatedly executed while condition evaluates to true.
Returns:
The result of the last execution of the body block or the null object if the body was never executed.

Just for the sake of ilustration, you could define the while function like this:
	define while ( condBlock bodyBlock ) {
	    if $condBlock {
		[lambda () $bodyBlock]
		while $condBlock $bodyBlock
        }
	}
	
Mind you this would not be particularly efficient, since tail recursion is not implemented in the current version of the Tea interpreter.

Overview Module Function Class Tea 3.2.5 Reference Documentation
© 2009 PDM&FC
Report a bug or request new features
© 2009