help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

while condition


From: SZABO Sandor
Subject: while condition
Date: Tue, 06 Mar 2001 15:04:42 +0100

Hello,

In doc I found the following ones:

function f (...)
  while (nargin--)
    disp (va_arg ())
  endwhile
endfunction

------

Octave's while statement looks like this:

while (condition)
  body
endwhile

Here body is a statement or list of statements that we call the body of
the loop, and condition is an expression that controls how long the loop

keeps running.

The first thing the while statement does is test condition. If condition
is true, it executes the statement body. After body has been executed,
condition is tested again, and if it is still true, body is executed
again. This process repeats until condition is no longer true. If
condition is initially
false, the body of the loop is never executed.

This example creates a variable fib that contains the first ten elements
of the Fibonacci sequence.

fib = ones (1, 10);
i = 3;
while (i <= 10)
  fib (i) = fib (i-1) + fib (i-2);
  i++;
endwhile

-----------
I would like to know what is the condition in

    while (nargin--)

Sandor Szabo




-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]