Questions tagged [equivalence]

Equivalence is a relationship in which two or more identifiers are abstractions for the same data structure.

References

168 questions
5
votes
1 answer

Equivalence Classes LISP

I need to write a program for equivalence classes and get this outputs... (equiv '((a b) (a c) (d e) (e f) (c g) (g h))) => ((a b c g h) (d e f)) (equiv '((a b) (c d) (e f) (f g) (a e))) => ((a b e f g) (c d)) Basically, A set is a list in…
bubdada
  • 343
  • 1
  • 3
  • 10
4
votes
3 answers

Name equivalence question

Suppose I have: int a; int b; Are the variables a and b name equivalent (more specifically, since primitive types don't have type names, can they be considered name equivalent)? Thanks.
John Kurlak
  • 6,594
  • 7
  • 43
  • 59
4
votes
3 answers

What makes two type expressions in Haskell equivalent?

So I was asked whether these 3 type expressions where equivalent in Haskell: τ1 = (a -> a) -> (a -> a -> a) τ2 = a -> a -> ((a -> a) -> a) τ3 = a -> a -> (a -> (a -> a)) if I take away the parenthesis I'm left with this τ1 = (a -> a) -> a -> a ->…
4
votes
1 answer

What do the Guava JavaDocs mean by sets being based on different "equivalence relations"?

The Guava JavaDocs for Sets.SetView.union() (as well as intersection(), difference(), and symmetricDifference()) mention "equivalence relations": Results are undefined if set1 and set2 are sets based on different equivalence relations (as HashSet,…
Christian
  • 6,070
  • 11
  • 53
  • 103
4
votes
1 answer

Are "unit-relevant" CSS property values with prepended zeroes equivalent to the corresponding "no-zeroes-prepended" values?

I was scanning some stylesheets when I noticed one which used a linear-gradient with rgba() color-stops in which the rgba numbers used multiple instances of 0 instead of just a single 0: background-image:linear-gradient(to top left,…
4
votes
2 answers

Is it really necessary to hash the same for classes that compare the same?

Reading this answer it seems, that if __eq__ is defined in custom class, __hash__ needs to be defined as well. This is understandable. However it is not clear, why - effectively - __eq__ should be same as self.__hash__()==other.__hash__ Imagining a…
Lukas
  • 2,232
  • 3
  • 21
  • 34
4
votes
2 answers

Making nested for loops in R more efficient

I am working on a research project where I want to determine equivalence of two distributions. I am currently using the Mann-Whitney Test for Equivalence and the code I am running (below) was provided with the book Testing Statistical Hypotheses of…
elaw10
  • 43
  • 3
4
votes
1 answer

What is the equivalence of python "type(, , )" in c++?

Alright so, I'm embedding python 3.3 into a c++ application. I'm looking to dynamically create a python class on the c++ side exactly like if I was doing the following in python: my_type = type("MyType", (object,), dict()) I know I could always…
John Smith
  • 187
  • 1
  • 9
4
votes
1 answer

Primitives and Object Wrapper Equivalence in JavaScript

EDIT: Based on everyone's feedback, the original version of this question is more design-related, not standards-related. Making more SO-friendly. Original: Should a JS primitive be considered "equivalent" to an object-wrapped version of that…
4
votes
1 answer

In R, how can I test if two factors are equivalent?

I am generating a big list of factors with different levels, and I want to be able to detect when two of them define the same partition. For example, I want to detect all of the following as equivalent to each other: x1 <- factor(c("a", "a", "b",…
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
3
votes
3 answers

What is the java equivalence to the C#-DateTime?

I have this function below. It recieves a string and a key made out of another string. The function takes the inputs and adds on the date to make the exact same key to validate. public bool isSecureKeyCorrect(string inputs,string thatKey) { …
Jens Bergvall
  • 1,617
  • 2
  • 24
  • 54
3
votes
3 answers

Question about reversed lists in Python

I am very new to python, as you will be able to tell. If I have a list: a = [1,2,3,2,1] This evaluates to true: a == a[::-1] ...but this evaluates to false: a == a.reverse() Why is that the case?
Mike Webb
  • 8,855
  • 18
  • 78
  • 111
3
votes
2 answers

Python __hash__: identity vs. equivalence

I have a class whose instances are to be distinguished by an identity that is different from the data values they carry. In my code, I intend to use == to mean two instances are equivalent regarding their data, and is to mean two variables refer to…
3
votes
2 answers

Find equivalent words in a list through arbitrary mapping

Imagine you have a list of words: ['cat', 'ant', 'bro', 'gro'] Using some arbitrary mapping that we construct ourselves {'c'=>'a', 'a'=>'n', 't'=>'t' }, we can map 'cat' to 'ant', and similarly we can find some arbitrary mapping to convert 'bro' to…
robinhood91
  • 1,641
  • 3
  • 20
  • 36
3
votes
2 answers

In Matlab, how do I compare two container.Map objects element-wise?

I have two container.Map objects, with identical keys and values. Is there a Matlab function, that is going to return true in the following scenario: >> m1 = containers.Map('hi', 'ho'); >> m2 = containers.Map('hi', 'ho'); >> m1 == m2 ans = 0
Anton Daneyko
  • 6,528
  • 5
  • 31
  • 59
1 2
3
11 12