Yep - I think in this case there may be a middle ground, something like:
Case High(Files) of 0..29 : factor := 1; 30..299 : factor := 2; .. Else .. End Max := Bias.Position * factor; More efficient than if/else if/else if and arguably even clearer in establishing that the threshold values of High(files) affect a multiplier that is applied to a consistent value to obtain the result (something that the if/else if/else if itself obfuscates by spreading that detail over multiple repeated lines) Of course, that assumes that the question was attempting to reduce the statement to a one-liner with the aim of improving efficiency and code legibility. J From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Colin/Mina Sent: Tuesday, 11 January 2011 15:08 To: NZ Borland Developers Group - Delphi List Subject: Re: [DUG] Maths problem for the day That was my point, the original describes exactly what was intended. One liners generally don't and tend to introduce errors C. ----- Original Message ----- From: Jolyon Smith <mailto:jsm...@deltics.co.nz> To: 'NZ Borland Developers Group - Delphi List' <mailto:delphi@delphi.org.nz> Sent: Tuesday, January 11, 2011 2:47 PM Subject: Re: [DUG] Maths problem for the day Darn, I got carried away... it's not quite that straightforward (unless your algorithm can be adjusted accordingly). From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of Ross Levis Sent: Tuesday, 11 January 2011 14:25 To: 'NZ Borland Developers Group - Delphi List' Subject: [DUG] Maths problem for the day Convert the following into one line. if High(Files) < 30 then Max := Bias.Position else if High(Files) < 300 then Max := Bias.Position*2 else if High(Files) < 3000 then Max := Bias.Position*3 else if High(Files) < 30000 then Max := Bias.Position*4 etc I think there must be a way. Probably using the Power function, but I can't get my head around it. _____ _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe