digitalmars.D - Filtering even numbers in various languages
- Andrei Alexandrescu (3/3) Feb 08 2011 https://gist.github.com/817504
- bearophile (6/9) Feb 08 2011 Good :-)
- Andrei Alexandrescu (3/6) Feb 08 2011 Added a comment too (andralex).
- Christopher Nicholson-Sauls (6/11) Feb 08 2011 I would argue that (a & 1 == 0) is a cheaper simple test for evenness...
- spir (9/20) Feb 09 2011 Isn't this, precisely, a typical case of expected compiler rewrite? whil...
- Max Samukha (3/6) Feb 09 2011 I am amazed at how Java guys still prefer their crappy, noisy and
- bearophile (4/6) Feb 09 2011 Well, compared to C++, a Java programmer needs to keep in mind far less ...
- Max Samukha (4/10) Feb 09 2011 I was referring to the particular posters who praised the Java solution,...
https://gist.github.com/817504 I added a D version. Andrei
Feb 08 2011
Andrei:https://gist.github.com/817504 I added a D version.Good :-) They have missed the lazy Python2.x version: (x for x in xrange(1, 5) if not x % 2) Bye, bearophile
Feb 08 2011
On 2/8/11 8:02 PM, Andrei Alexandrescu wrote:https://gist.github.com/817504 I added a D version. AndreiAdded a comment too (andralex). Andrei
Feb 08 2011
On 02/08/11 19:02, Andrei Alexandrescu wrote:https://gist.github.com/817504 I added a D version. AndreiI 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
Feb 08 2011
On 02/09/2011 07:02 AM, Christopher Nicholson-Sauls wrote:On 02/08/11 19:02, Andrei Alexandrescu wrote: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.comhttps://gist.github.com/817504 I added a D version. AndreiI 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
Feb 09 2011
On 02/09/2011 03:02 AM, Andrei Alexandrescu wrote:https://gist.github.com/817504 I added a D version. AndreiI am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority.
Feb 09 2011
Max Samukha:I am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority.Well, compared to C++, a Java programmer needs to keep in mind far less arbitrary details, that if forgotten cause many bugs in C++ programs. Java compiler is strict and catches many bugs, it works well enough, and you just need small jars to distribute the compilation result. Today Java works on many machines, on 32 and 64 bit well enough, there are tons of libraries, Java programmers that you are able to hire, tons of tools to edit/debug/improve Java code, Java is today pretty fast and its GC is first world class. There are even other languages like Scala and Jthon that run on the JVM and interoperate with it and its libs. Given all that, the verbose syntax of Java becomes a minor thing. Java is full of faults and downsides, but most other languages/language ecosystems are worse. Bye, bearophile
Feb 09 2011
On 02/09/2011 08:06 PM, bearophile wrote:Max Samukha:I was referring to the particular posters who praised the Java solution, which is obviously inferior to nearly every 'filter' variant provided by other posters.I am amazed at how Java guys still prefer their crappy, noisy and efficient way. And sadly they represent the majority.Well, compared to C++, a Java programmer needs to keep in mind far less arbitrary details, that if forgotten cause many bugs in C++ programs. Java compiler is strict and catches many bugs, it works well enough, and you just need small jars to distribute the compilation result. Today Java works on many machines, on 32 and 64 bit well enough, there are tons of libraries, Java programmers that you are able to hire, tons of tools to edit/debug/improve Java code, Java is today pretty fast and its GC is first world class. There are even other languages like Scala and Jthon that run on the JVM and interoperate with it and its libs. Given all that, the verbose syntax of Java becomes a minor thing. Java is full of faults and downsides, but most other languages/language ecosystems are worse. Bye, bearophile
Feb 09 2011