2,251 questions
9
votes
1
answer
615
views
std::equal_to<void>{}(A1, B1) does not compile, while A1 == B1 compiles in C++26 for unscoped enums?
I noticed a discrepancy between C++23 and C++26 code when using googlemock:
enum A { A1, A2 };
enum B { B1, B2 };
TEST(...)
{
ASSERT_EQ(A1, B1); // compiles fine in C++23 and C++26
ASSERT_THAT(...
Advice
0
votes
4
replies
126
views
Test Equality of Infinite Lists
In Haskell, how should one test the equality of two infinite lists?
With finite lists, one might try:
listEqual :: Eq a => [a] -> [a] -> Bool
listEqual l0 l1 = and $ zipWith (==) l0 l1
But ...
Tooling
0
votes
2
replies
59
views
using optional chaining with === in case of both 'undefined'
I am using optional chaining quite often, but so far never encounter that issue, until today:
if both items can be undefined, rather don't use optional chaining. Only last test (below) can help in ...
0
votes
1
answer
102
views
.NET Equals override not being called inside FirstOrDefaultAsync
I'm in a .NET 6 web application with EFCore, and I have these boilerplate abstract classes and interfaces for defining entities. I know it's quite a number of complexity layers, but it really helps me ...
3
votes
2
answers
273
views
Why does "\0" give integer in c
So, I am learning C language and was trying to make a function that returns the length of a string. In the if statement I mistakenly used "" instead of ''. So, instead of comparing to char '\...
0
votes
3
answers
97
views
is there a difference between elements created dynamically with JavaScript and elements in HTML
take the code below:
contentsDiv.innerHTML = container.outerHTML;
if(contentsDiv.firstChild === container) console.log('true');
in this code, contentsDiv is a div created in my html file ...
1
vote
1
answer
165
views
Why can't an equality check be performed via operator!=? [duplicate]
struct Equal
{
friend bool operator==(const Equal&, const Equal&);
};
struct Unequal
{
friend bool operator!=(const Unequal&, const Unequal&);
};
int main()
{
Equal{} == ...
-1
votes
3
answers
299
views
Why don't anonymous types overload the == and != operators (but records do)? [closed]
The Equals and GetHashCode methods on anonymous types are overridden to make them work in such a way that two instances of the same anonymous type are considered equal only if all their properties are ...
1
vote
1
answer
181
views
Is there an easier way to check if two elements in a Rust array are equal?
I have an array:
let mut zobrist_pieces = [[0u64; 64]; 12];
for i in 0..12 {
for j in 0..64 {
zobrist_pieces[i][j] = rng.random();
}
}
and I want to check if there is any way to find ...
0
votes
1
answer
78
views
Python pickled object equality guarantees
I am wondering if, and if so which guarantees there are about the pickle module when using pickle.dump[s].
Specifically for my problem I am pickling list[T] where T can be bool, int, decimal, time, ...
0
votes
2
answers
96
views
How do I use g_assert_cmpfloat () to check if two floats are equal without generating a safety warning?
I'm writing some testcases for a program using the GLib testing facilities. I want to assert that two floats have the same value, and g_assert_cmpfloat () seemed like an appropriate function for that. ...
1
vote
4
answers
134
views
Class I made not showing up as equal when equal [closed]
I have a custom class for holding a collection of quotes in swiftData in my app.
It looks like this:
@Model
final class CollectionData: Equatable {
var name: String
var data: [Quote]
var ...
0
votes
0
answers
96
views
How to verify that two files are equal using Java AWS SDK
I am looking for the way how to compare two files (especially large files) in S3 within the same bucket using Java AWS SDK.
I do not need to verify whole bucket if there are duplicates. As I ...
0
votes
2
answers
105
views
Is it possible to create an equals override for an untyped class and it's typed counterpart?
I have two classes, non-generic BindingFilter and generic BindingFilter<T>:
public class BindingFilter
{
public object Value { get; set; }
public string Member { get; set; }
...
3
votes
1
answer
275
views
operator== ambiguity in C++20
Why is this code ambiguous starting with C++20?
template <typename T>
struct base_widget {
bool operator==(T const&) const;
};
struct gadget : base_widget<gadget> {};
bool foo(...
0
votes
0
answers
44
views
How to implement a custom equality comparison which can test pd.DataFrame attributes?
I have a custom dataclass, which is rather lage (many attributes, methods). Some attributes are pandas dataframes. The default __eq__ comparison does not work for the attribtues which are pandas ...
0
votes
3
answers
112
views
Equality and identity in Dart
I am just starting to study Dart and a question arose, a clear answer to which I could not find or formulate for myself.
I'm trying to figure out the difference between == and identity(). Using the ...
0
votes
1
answer
108
views
Compare coefficients across different regressions in R
I would like to test if the coefficients across different regressions are the same in R and I am not sure how I should do it.
Let me illustrate. I have an independent variable of interest called treat
...
0
votes
1
answer
73
views
How to Notify the Agda Type-Checker that two Types are Indeed Equal?
Here is a minimum (not-)working example.
infix 4 _≡_
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
refl : x ≡ x
{-# BUILTIN EQUALITY _≡_ #-}
data Type₁ : Set where
id : Type₁
non-id ...
0
votes
2
answers
216
views
Comparing reference type Objects by value without overwriting Equals methods manually
This might be a beginners question, but I have a problem for which I could not find an existing solution and was hoping you could help me here.
I would like to compare instances of a reference type ...
1
vote
2
answers
46
views
Cannot check equality for two-dim arrays of equatable tuples
I don't understand the following situation:
let a1: [[Double]] = [[1]]
let equ1 = a1 == a1 // This builds
let t1: (Double, Double) = (1, 1)
let equ2 = t1 == t1 // This builds also
let a2: [[(Double, ...
0
votes
1
answer
93
views
Verifying all objects in a Kotlin collection match without overriding equals
I am working on a kotlin function that needs to verify that all objects in a collection have the same value for a particular property. Normally I would simply use distinctBy() and check that the size ...
1
vote
1
answer
75
views
Testing for equality between a uint8_t and an inverted uint8_t does not work as expected [duplicate]
While debugging my implementation of YMODEM on an embedded system, I noticed that some code comparing a uint8_t and the inverse of a uint8_t is not behaving as I expected, but I don't really ...
3
votes
1
answer
510
views
Override Equals method on records
Consider this Minimal Reproducible Example.
Point point1 = new Point(1, 2, 3);
Point point2 = new Point(1, 2, 31);
Console.WriteLine(point1 == point2); // True
Console.WriteLine(point1.Equals(point2)...
1
vote
1
answer
107
views
several custom __eq__ for python classes in context of serialization
Assume I have some complex class structure with some hierarchy, public and private fields.
I need to do some custom serialization for such class. In some test after deserialize I want to compare ...
1
vote
2
answers
424
views
Efficiently check for equality of memory blocks in C/C++
I'm interested in the most efficient way to check for equality of memory blocks.
Currently, I use memcmp(...) == 0 to determine if two memory blocks are equal. While this works, memcmp is designed not ...
0
votes
0
answers
100
views
Haskell Typeclass for non-transative equality
I know that the laws for the Eq class include reflectivity, symmetry, and transitivity. Is there another class for the case where equality is not necessarily transitive?
I could write one myself (see ...
-3
votes
3
answers
2k
views
Compare lists of string in terraform
What's the best way to compare two lists of string in terraform?
["arm64"] == ["arm64"] evaluates to false
My use case is constructing lambda extension ARNs based on ...
0
votes
1
answer
87
views
How do I compare 2 elements (variable prices) in Cypress?
I am testing the eshop.
I'm trying to verify that if you buy one product, the price will be the same as the final purchase price.
The first element "Final Price" is calculated by the price ...
3
votes
3
answers
248
views
Understanding the details of equality in Python
When trying to construct an example where a == b is not the same as b == a, it seems that I have accidentally constructed an example where a == b is not the same as a.__eq__(b):
class A:
def ...
2
votes
3
answers
338
views
.NET combine hash codes insensitive to order
I'm looking for an implementation of hash code to use alongside IReadOnlySet<T>.SetEquals.
.NET's HashCode type appears to be order sensitive, so it is not a good fit.
var random = new Random();
...
3
votes
1
answer
377
views
Comparing hashtables in Pester
What's the correct way to compare hashtables in Pester tests?
i.e. the following gives the error: InvalidResult: Expected System.Collections.Hashtable, but got System.Collections.Hashtable.
$expected =...
-4
votes
1
answer
151
views
How do Java's equality tests (`==`) work between same primitives (e.g. int, char) and what is most efficient?
How do Java's equality tests work between primitives? I'm specifically looking for efficiency (and speed) within single-type comparisons. Is the char == char comparison faster than int == int?
I ...
8
votes
1
answer
343
views
A type with `Eq a` but not `Ord a`
In (an idealized version of) Haskell, is there a concrete type a such that we can implement Eq a lawfully, but it is impossible to implement Ord a? The order doesn't need to be meaningful, and any ...
0
votes
2
answers
112
views
Uniqueness of a record containing a collection
I am using C# records in a HashSet to enforce uniqueness. This works well, but as soon as the record contains a Collection then it stops working.
ie. this passes:
public record Person
{
public ...
0
votes
1
answer
78
views
How to solve an inequality that contains standard deviation in python?
I have the past 19 days of stock price stored in the pd.dataframe and I am trying to find out the price P that is smaller than (mean - 2.5*standard deviation), where mean and standard deviation are ...
0
votes
2
answers
135
views
In Tcl, why do I have to use quotes and curly braces for expr's argument when comparing two string literals?
I wanna compare two literal strings using expr command in Tcl. The correct command is:
expr {"string1" == "string1"}
In my understanding, curly braces in Tcl is used to prevent ...
1
vote
1
answer
159
views
== and Equals for Tuple<object>
i have a question why it works like this
var a = new Tuple<object, object, object>(1, 1, 1);
var b = new Tuple<object, object, object>(1, 1, 1);
Console.WriteLine(a.Item1==b.Item1);//...
2
votes
1
answer
764
views
Custom equality comparator for set operation in Kotlin
As mentioned here: Efficient way to compare an partition two collections in Kotlin I am working on a Kotlin application that needs to compare lists of Json objects. To find the elements that are ...
0
votes
1
answer
117
views
Is there anything wrong with checking two hex values using == in C? [closed]
Code:
#include<stdio.h>
#include<stdlib.h>
unsigned char
s(const unsigned char x) {
static const unsigned char aes_s_box[16][16] = {
{0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F,...
1
vote
2
answers
78
views
Why is null Unity Object equal to null in specialized class but not equal to null in generic class?
Attach TestMono to an empty GameObject, leave the serialized field uov empty and play. The result is not what I expected.
using System;
using UnityEngine;
using Object = UnityEngine.Object;
namespace ...
0
votes
2
answers
233
views
c# equality check for class containing reference type properties
If we have a class that contains properties/fields of other reference types, how would a proper and elegant equality check be performed?
For example, MainClass contains properties of SubClassA and ...
0
votes
0
answers
29
views
What is the correct way to compare static immutable strings and mutable strings in Rust? [duplicate]
I am new to Rust & I am having trouble to compare mutable strings and immutable strings.
Please find below a code block which should exit if "exit" is entered.
But I am having problem ...
1
vote
0
answers
31
views
angularjs, filtering, returning equal results
I am filtering using AngularJS. Everything works fine, but I want a filter to work differently. If "1" is searched, the result should only be "1". I would like your help regarding ...
4
votes
2
answers
403
views
Why is "".equals(1) Valid but "" == 1 Invalid in Kotlin?
I'm currently learning Kotlin and encountered a behavior that I find puzzling. Here are the two lines of code that have me confused:
"".equals(1) // not compile error
"" == 1 // ...
-2
votes
1
answer
62
views
Why is my while loop with python not working? [duplicate]
I wrote this code to ask the user for options A, B, or C and show a message afterward, but even if I type the correct options, it still sends me the 'try again' message. what can I do so the program ...
1
vote
2
answers
320
views
How to compare l and ł (Polish character) in c# to return true
I am trying to compare the following two characters l and ł and get c# to return true
i.e. I have the word Przesyłka and would like to do a string comparison to Przesylka
I have tried the following ...
1
vote
0
answers
55
views
In MATLAB, why does arr==el sometimes fail to find element el in array arr? [duplicate]
In MATLAB R2016a, suppose that I define the array arr = -0.2:0.1:0.2. I may then find the location of the value el = 0.1 with the command idx = find(arr==el). This correctly yields idx = 4.
But now ...
2
votes
3
answers
6k
views
Is there a better way to deeply compare two objects?
I would like to know if there is a better way to compare objects in JavaScript.
I understand that there are many large solutions but I would like to get a clear answer if their is a simple way to do ...
2
votes
0
answers
63
views
In Scala 3, should 2 dependent types that depends on 2 equal & singleton objects perceived to be equal? Why or why not?
In the following example (my attempt to mimic section feature of LEAN4 prover), I have declared 2 special axioms that allows 2 objects of type Gen[T] to be perceived equal and can be cast to each ...