<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-NZ link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Yep – I think in this case there may be a middle ground, something like:<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Case High(Files) of<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> 0..29 : factor := 1;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> 30..299 : factor := 2;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> ..<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Else<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> ..<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> End<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'> Max := Bias.Position * factor;<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>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)<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>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. <o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-family:Wingdings;color:#1F497D'>J</span><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> delphi-bounces@delphi.org.nz [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>Colin/Mina<br><b>Sent:</b> Tuesday, 11 January 2011 15:08<br><b>To:</b> NZ Borland Developers Group - Delphi List<br><b>Subject:</b> Re: [DUG] Maths problem for the day<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>That was my point, the original describes exactly what was intended. One liners generally don't and tend to introduce errors</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>C.</span><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'> <o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>----- Original Message ----- <o:p></o:p></span></p></div><blockquote style='border:none;border-left:solid black 1.5pt;padding:0cm 0cm 0cm 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><div><p class=MsoNormal style='background:#E4E4E4'><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <a href="mailto:jsmith@deltics.co.nz" title="jsmith@deltics.co.nz">Jolyon Smith</a> <o:p></o:p></span></p></div><div><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>To:</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> <a href="mailto:delphi@delphi.org.nz" title="delphi@delphi.org.nz">'NZ Borland Developers Group - Delphi List'</a> <o:p></o:p></span></p></div><div><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Sent:</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> Tuesday, January 11, 2011 2:47 PM<o:p></o:p></span></p></div><div><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Subject:</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> Re: [DUG] Maths problem for the day<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='color:#1F497D'>Darn, I got carried away... it’s not quite that straightforward (unless your algorithm can be adjusted accordingly).<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> <a href="mailto:delphi-bounces@delphi.org.nz">delphi-bounces@delphi.org.nz</a> [mailto:delphi-bounces@delphi.org.nz] <b>On Behalf Of </b>Ross Levis<br><b>Sent:</b> Tuesday, 11 January 2011 14:25<br><b>To:</b> 'NZ Borland Developers Group - Delphi List'<br><b>Subject:</b> [DUG] Maths problem for the day<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>Convert the following into one line.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>if High(Files) < 30 then Max := Bias.Position<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>else if High(Files) < 300 then Max := Bias.Position*2<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>else if High(Files) < 3000 then Max := Bias.Position*3<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>else if High(Files) < 30000 then Max := Bias.Position*4<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>etc<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'>I think there must be a way. Probably using the Power function, but I can’t get my head around it.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:12.0pt;color:#1F497D'><o:p> </o:p></span></p><div class=MsoNormal align=center style='text-align:center'><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'><hr size=2 width="100%" align=center></span></div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman","serif"'>_______________________________________________<br>NZ Borland Developers Group - Delphi mailing list<br>Post: delphi@delphi.org.nz<br>Admin: http://delphi.org.nz/mailman/listinfo/delphi<br>Unsubscribe: send an email to delphi-request@delphi.org.nz with Subject: unsubscribe<o:p></o:p></span></p></blockquote></div></body></html>