Access to Fields of Records
Fields of a record are accessed by specifying a pointer to the record, an operator for dereferencing the pointer (i.e., changing from the pointer to what it points to), and the name of the field.
| Scheme | (cdr p) |
| Pascal | p^.cdr |
| C++ | p->cdr |
| Java | p.cdr |
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
} ) )
Contents    Page-10    Prev    Next    Page+10    Index