67 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
48
views
Agda: cannot instantiate metavariable
I'm fairly new to Agda and I'm trying to construct the Interval's lattice. So far I've defined the Lattice datatype as follows:
data I : Set where
⊤ : I
⊥ : I
-∞ : Z → I
_+∞ : Z → I
I : ...
1
vote
1
answer
81
views
Motivating pure functions: are all pure functions commutative in execution order?
I’m trying to understand whether all pure functions are commutative with respect to execution order. That is, does the order in which pure functions are executed ever matter, assuming no external ...
0
votes
2
answers
124
views
Why only commutativity is sufficient for op-based CRDTs and not also associativity?
In the context of op-based CRDTs, it has been shown that a sufficient condition to ensure convergence (Strong Eventual Consistency) is that all operations commute. (assuming an underlying reliable ...
0
votes
2
answers
103
views
C# Commutativity in if statements [closed]
Is there a way to essentially write "and vice versa" in an if statement without writing the same code again but with "||"?
if (currentDirection == 1 && nextDirection == 2)
...
4
votes
1
answer
145
views
When cppreference says that * should be overloaded as a free function for "symmetry", does "symmetry" mean commutativity?
I have implemented a class vec3:
struct vec3 {
double x = 0, y = 0, z = 0;
auto& operator*= (double d) {x *= d; y *= d; z *= d; return *this;}
};
auto operator* (const vec3 &a, double ...
0
votes
2
answers
110
views
Ordering of keys in dictionaries using SymPy
I have the following problem with my code. I start off with a polynomial (f = 3x+2y+xy), and want to store the coefficients and variables in separate lists (I want to be able to change this polynomial ...
2
votes
2
answers
185
views
Non-commutative expansion of brackets (Python)
I wanted to ask whether there is a method to expand brackets in Python non-commutatively. For example,
INPUT (x+y)**2, OUTPUT x**2 + x*y + y*x + y**2,
instead of the usual output x**2 + 2*x*y + y**2.
...
1
vote
1
answer
275
views
Homomorphic and non-commutative hash function?
Does a non commutative homomorphic hash function exist (or been researched/published)?
LtHash developed by Facebook and implemented on Github here is the sort of function I am looking for, but LtHash ...
0
votes
2
answers
84
views
Map a list to a value with non commutative function in haskell [duplicate]
Hello I have a function foo (Int -> Int -> Int) in haskell and I want to map each element of a list [1..y] to a value x which I would usually do like this:
map (foo x) [1..y]
the problem is my ...
0
votes
1
answer
73
views
JavaScript commutative behavior for function call. Needed pointers for what exactly happens behind scenes
I have following code and want to check commutative property with impure functions. Can anyone explain why the first two console log print 3, 3 and why the direct function call print 3 and -3?
var ...
11
votes
2
answers
751
views
Addition of NA and expression that evaluates to NaN return different results depending on order, violation of the commutative property?
I am investigating corner cases of numeric operations in R. I came across the following particular case involving zero divided by zero:
(0/0)+NA
#> [1] NaN
NA+(0/0)
#> [1] NA
Created on 2021-07-...
3
votes
1
answer
324
views
Require commutative operation in Rust trait bound
Suppose I have a group of related non-scalar structs with a commutative arithmetic operation defined on them. For example,
struct Foo {
a: f64,
b: f64
}
impl Add<f64> for Foo {
type ...
1
vote
4
answers
111
views
Is the order of the equality operator important in Ruby?
I have used the bcrypt library in my Ruby program. I noticed that the order of the equality operator seems to be important. Depending on which variable is left or right of the '==' I get a different ...
1
vote
2
answers
278
views
@lru_cache on function with commutative arguments
I am calculating the Hamming distance between 2 strings where Hamming(A,B) == Hamming(B,A)
The function signature is
@lru_cache
def Hamming(A:str,B:str)->int:
...
How can I modify @lru_cache ...
1
vote
2
answers
751
views
Are coalesce + orderBy commutative in Spark?
I want to run the following code:
df = df.coalesce(1).orderBy(["my_col"])
but its execution will obviously bottleneck on a single task doing all the sort work.
I know it's possible to run ...