If you have a loop where the exit condition test is a significant contribution to the time, then we should look at the loop to answer these questions, as it will depend on what else you're doing there. (This seems like a rare situation to me, but not entirely out of the realm of possibility).
Otherwise, I'd ignore the speed issue. Robby On Thu, Sep 27, 2012 at 11:10 AM, Tim Brown <[email protected]> wrote: > What is the difference in correctness between "(= x 0)" vs. "(zero? x)"? > > Fast is relevant to some questions (solutions) I have -- terminating tight > loops etc. And given a choice of (eq? 0 x), (= 0 x) and (zero? x), which > would, and which should take the shortest time to perform 10^12 times? > > Maybe I'm thinking a bit too much like a C programmer -- (!x)... works for > me as a test in so many ways; that I tend to want to use something like it > when I'm writing in other languages. (Where I should be using zero? false? > and/or null?). > > Tim > > On 27/09/12 16:50, Matthias Felleisen wrote: >> >> Fast is so irrelevant for this question. >> >> Correct is what really matters. >> >> >> >> On Sep 27, 2012, at 11:45 AM, Tim Brown wrote: >> >>> On 26/09/12 15:31, Marco Morazan wrote: >>>> >>>> 1. Is eq? the most natural way to test the equality of numbers? (minor >>>> quibble) >>> >>> >>> I was wondering this, myself, earlier, but is zero? the fastest way to >>> test for zero-ness? >>> >>> Tim > > > -- > Tim Brown <[email protected]> | City Computing Limited | > T: +44 20 8770 2110 | City House, Sutton Park Road | > F: +44 20 8770 2130 | Sutton, Surrey, SM1 2AE, GB | > -----------------------------------------------------------------------| > BEAUTY: What's in your eye when you have a bee in your hand | > -----------------------------------------------------------------------' > City Computing Limited registered in London No. 1767817. > Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE > VAT number 372 8290 34. > ____________________ > Racket Users list: > http://lists.racket-lang.org/users ____________________ Racket Users list: http://lists.racket-lang.org/users

