while - do Statement

Scheme (while test code )
Pascal while test do code
C++, Java while ( test ) code

If multiple statements are to be executed within the while loop in Pascal, a begin ... end must be used.


long length (cons *l)    (define (length2 l)
  {
    long n;               (let ((n 0))
    n = 0;
    while ( l != NULL )    (while (not (null? l))
        {
          ++n;               (set! n (1+ n))
          l = l->cdr;        (set! l (cdr l))
        }                   )
    return n;              n
  }                       ) )

There is also a statement with the test at the end:

C++, Java do code while ( test )

Contents    Page-10    Prev    Next    Page+10    Index