the 'broken' statement - (nf)
essick at uiuccsb.UUCP
essick at uiuccsb.UUCP
Fri Oct 14 13:35:30 AEST 1983
#R:utzoo:-323200:uiuccsb:9000003:000:946
uiuccsb!essick Oct 13 13:34:00 1983
Seems to me that the easiest way to implement the "first i in list"
construct in C is the following:
for ( i=0;i < Limit; i++) /* check the candidates */
if ( condition )
break;
if ( i == Limit ) /* or whatever it asumes */
{ /* when it overruns the list */
not found;
}
else
{
found; /* and it is element "i" */
}
If the collection of items to be checked is a linked list, change
the appropriate for conditions and make the found/notfound test
a comparison to NULL.
How would you specify the list? Is it always an array? a linked list?
a binary tree? a completely specified list of simple [== non array]
variables? Have the compiler understand about all these data structures?
Blech.
The only case I can think where this might help is in PASCAL where
you don't have a break statement; PASCAL would benefit more from
adding a break statement than adding this construct.
-- Ray Essick, University of Illinois
More information about the Comp.lang.c
mailing list