Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site methods.UUCP Path: utzoo!watmath!methods!cary From: cary@methods.UUCP (Cary Timar ) Newsgroups: net.lang.c,net.bugs Subject: Re: e1?(void_e2):(void_e3) so, is it legal or what? Message-ID: <114@methods.UUCP> Date: Mon, 25-Aug-86 20:26:05 EDT Article-I.D.: methods.114 Posted: Mon Aug 25 20:26:05 1986 Date-Received: Thu, 28-Aug-86 04:11:41 EDT References: <518@hadron.UUCP> <243@desint.UUCP> <745@wjvax.wjvax.UUCP> <248@desint.UUCP> Reply-To: cary@methods.UUCP (Cary Timar (U of W co-op)) Organization: Methodsworks, Inc., Burlington, Ont. Lines: 32 Xref: watmath net.lang.c:10340 net.bugs:887 Summary: In article <248@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes: > >Unfortunately, Brett is incorrect here. You can't use if/then/else to write: > > for (i = up ? 0 : 99; up ? (i < 100) : (i >= 0); up ? i++ : i--) > { > /* complex loop body */ > } > >without duplicating code. On the other hand, anywhere you want do What about: if (up) { i = 0; step = 1; } else { i = 99; step = -1; } for (; i < 100 && i >= 0; i += step) { /* complex loop body */ } ???? -- Cary Timar /* NOT REACHABLE */ < Generic Disclaimer >