Filtering even numbers in various languages

spir denis.spir at gmail.com
Wed Feb 9 04:20:17 PST 2011


On 02/09/2011 07:02 AM, Christopher Nicholson-Sauls wrote:
> On 02/08/11 19:02, Andrei Alexandrescu wrote:
>> https://gist.github.com/817504
>>
>> I added a D version.
>>
>> Andrei
>
> I would argue that (a&  1 == 0) is a cheaper simple test for evenness...
>
> </gratuitous-nitpick>
>
> Good show.  Not really sure what the point of the list was... but
> sometimes these things are just (for) fun.
>
> -- Chris N-S

Isn't this, precisely, a typical case of expected compiler rewrite? while n%2 
far better expresses the concept in source (in absence of to-be-inlined 
isEven() or general isMultipleOf(), indeed).

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list