# [racket] How fast is zero? was: Find nth term of a List

On Thu, Sep 27, 2012 at 12:10 PM, Tim Brown <tim.brown at cityc.co.uk> wrote:
>* What is the difference in correctness between "(= x 0)" vs. "(zero? x)"?
*
There is none: http://docs.racket-lang.org/reference/number-types.html?q=zero%3F#%28def._%28%28quote._~23~25kernel%29._zero~3f%29%29
>* 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?
*
(= 0 x) and (zero? x) should compile to the same code.
(eq? 0 x) produces simpler code, because:
(= 0 0.0) => #t, but (eq? 0 0.0) => #f.
For actual performance numbers, as opposed to reasoning from
instructions sequences, Robby's advice about benchmarking is very
wise.
--
sam th
samth at ccs.neu.edu