T(r)ip of the day?
- Posted by Matt Sephton <u5ms at CSC.LIV.AC.UK> Feb 21, 1997
- 980 views
Last night, whilst churning out lines of our lovely Eu, I needed to have a section of code which set a variable iPos to 1 if a variable iTotal was 1 and iPos to 2 otherwise. My first attempt was: if iTotal = 1 then iPos = 1 else iPos = 2 end if At closer inspection I managed to reduce this two one line of code, which is a hell of a lot more succinct and well faster. Comparing the number of assignments, lines and comparisons we can see that it is superior. iPos = (iTotal > 1) + 1 Well, I don't know if that will be of use, but it was for me. How about starting a little thread of tips like this? Especially when the Eu newsgroup gets going. Later, Matt Sephton -- u5ms at csc.liv.ac.uk http://www.csc.liv.ac.uk/~u5ms/