comparison
Python: max/min builtin functions depend on parameter order
In [19]: 1>float(‘nan’) Out[19]: False In [20]: float(‘nan’)>1 Out[20]: False The float nan is neither bigger nor smaller than the integer 1. max starts by choosing the first element, and only replaces it when it finds an element which is strictly larger. In [31]: max(1,float(‘nan’)) Out[31]: 1 Since nan is not larger than 1, 1 … Read more
Comparing two arrays ignoring element order in Ruby
The easiest way is to use intersections: @array1 = [1,2,3,4,5] @array2 = [2,3,4,5,1] So the statement @array2 & @array1 == @array2 Will be true. This is the best solution if you want to check whether array1 contains array2 or the opposite (that is different). You’re also not fiddling with your arrays or changing the order … Read more
What is the difference between google’s ImmutableList and Collections.unmodifiableList ()?
No, the immutability is only applied to the amount and references of the objects in the Collection, and does not address the mutability of objects you put in the Collection. What Immutable list gains over the standard JDK Collections.unmodifiableList is that by using ImmutableList you are guaranteed that the objects referenced, their order and the … Read more
How to properly compare decimal values in C#?
Your code will work as expected. C# decimals are optimized to be very accurate at representing base 10 numbers, so if that’s what you’re comparing (money, …), everything should be fine. Here’s a very clear explanation about the accuracy of decimals by Jon Skeet: Difference between decimal, float and double in .NET?
What is the correct way to compare char ignoring case?
It depends on what you mean by “work for all cultures”. Would you want “i” and “I” to be equal even in Turkey? You could use: bool equal = char.ToUpperInvariant(x) == char.ToUpperInvariant(y); … but I’m not sure whether that “works” according to all cultures by your understanding of “works”. Of course you could convert both … Read more
.net ORM Comparison [closed]
Since J. Tihon did a great job on explaining EF features, I’ll just list the areas where NHibernate runs circles around EF: Caching EF has nothing out of the box; there’s just an unsupported sample NH has complete caching support, including DB-based invalidation. It’s also extensible and provider-based, meaning it works with different types of … Read more
Which key/value store is the most promising/stable?
Which do you recommend, and why? I recommend Redis. Why? Continue reading!! Which one is the fastest? I can’t say whether it’s the fastest. But Redis is fast. It’s fast because it holds all the data in RAM. Recently, virtual memory feature was added but still all the keys stay in main memory with only … Read more
(…()) vs. (…)() in javascript closures [duplicate]
There’s no difference. Both are valid ways to get the JavaScript parser to treat your function as an expression instead of a declaration. Note that + and ! will also work, and are sometimes used by minifiers to save a character of size: +function() { var foo = ‘bar’; }(); !function() { var foo = … Read more
Which Haskell XML library to use?
I would recommend: xml, if your task is simple haxml, if your task is complex hxt, if you like arrows hexpat if you need high performance