[racket] How fast is zero? was: Find nth term of a List
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 <tim.brown at cityc.co.uk> | 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.