Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!houxm!whuxl!whuxlm!akgua!gatech!seismo!mcvax!boring!guido From: guido@boring.UUCP Newsgroups: net.lang.c Subject: Re: goto jumps into loops Message-ID: <6879@boring.UUCP> Date: Sat, 19-Apr-86 11:29:52 EST Article-I.D.: boring.6879 Posted: Sat Apr 19 11:29:52 1986 Date-Received: Wed, 23-Apr-86 20:11:20 EST References: <69@brl-smoke.ARPA> Reply-To: guido@mcvax.UUCP (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 26 Apparently-To: rnews@mcvax Dave Harmon obviously doesn't know C and didn't bother to test the C version of his example: it contains i=MAX instead of i==MAX and while(in(..)) instead of while(!in(...)) -- the latter no doubt stemming from a slavish translation of Pascal's until . Nevertheless, his problem is not one that's solved better with the use of goto's. Here's my code (tested -- it didn't need debugging :-). wrtlist(s) set *s; { int count= 0; /* Counts elements in range currently being printed */ int e; for (e= 0; e <= MAX; ++e) { if (in(e, s)) { if (count == 0) printf(" %d", e); ++count; } else { if (count > 1) printf("-%d", e-1); count= 0; } } } -- Guido van Rossum, CWI, Amsterdam