Questions tagged [compare]

The analysis required to assess the differences and similarities between two or more entities.

This tag is used to classify a question as one dealing with the comparison of at least two entities. The essence of questions that are tagged should boil down to one of the following questions:

  1. How do I control when the compiler/interpreter thinks that two entities are equal? How do I control when the compiler/interpreter thinks that two entities are unequal?
  2. How do I control when the compiler/interpreter thinks that one entity is bigger than the other?
  3. How do I control when the compiler/interpreter thinks that one entity is smaller than the other?

Note that in some languages, it is possible to define asymmetric inequalities. That is, cases in which a<b does not mean that b<a. This is why in python, there exist separate functions for __gt__ (greater than) and __lt__ (less than), etc

10212 questions
2
votes
2 answers

Weird behavior of std::is_sorted

I'm learning assertions in c++, and I came across weird behaviour of std::is_sorted. Given a comparator(c), and unsorted vector(v) of std::strings. I use std::sort(v.begin(),v.end(),comparator). and then call std::is_sorted with the same arguments.…
XYZCODE123
  • 372
  • 3
  • 12
2
votes
2 answers

Beyond Compare: compare whole function calls or xml blocks

I want to compare c and XML files with Beyond Compare. But I want to detect if there are differences within a Block to the corrosponding on the other file and if there is a difference in a block I dont want Beyond Compare to Show the difference in…
Loois95
  • 85
  • 12
2
votes
3 answers

Display a word if it's greater and another one if it's less than

Given the following PHP code, how can I display the word problems if the number is greater than one and how can I display the word problem if the output of the variable is 1 or 0? echo "$number problems";
Jacob K.
  • 115
  • 2
  • 16
2
votes
0 answers

How to compare two analytical equations for missing elements in Mathematica

I have two equations: (1) Eq1 = -((A N1 P (A B k (a N1 + aa P - r) + (d + A B r) R))/k) (2) Eq2 = R*N1*P, where R = (k (aa B m - a mm + A B r))/d; P = (-a^2 b k mm - A B m r + a k (aa bb m + A b B r))/(A d); N1 = (-aa^2 bb k m + A mm r + aa k (a b…
Rspacer
  • 2,369
  • 1
  • 14
  • 40
2
votes
2 answers

How to compare two arrays using tensorflow?

I need to compare two arrays and get either true or false,not elementwise result. My code is X = tf.constant([0.05, 0.10], dtype=tf.float32, shape=[1, 2]) y = tf.constant([0.01, 0.99], dtype=tf.float32, shape=[1, 2]) equality = tf.equal(X,…
Nija I Pillai
  • 1,046
  • 11
  • 13
2
votes
5 answers

PHP: compare substrings

Really quick noob question with php: I'm trying to create a conditional statement where I can check if a variable partially matches a substring. More specific in my case: $cal is the name of a file, I want it so if $cal contains ".cfg" it echos some…
dukevin
  • 22,384
  • 36
  • 82
  • 111
2
votes
4 answers

How to compare given keys from array list with HashMap keys?

In my WebApplication I have to check many incoming query parameters from the requestBody. In order not to write the same code in every method, I want to write a function that returns a boolean. When all required parameters are received and the…
Hubi
  • 440
  • 1
  • 11
  • 25
2
votes
2 answers

How to compare null value in PLSQL

Below is my code. One variable is NOT having value. Another variable is having a value. In the below code, I want to print that the variables are not same even in the case when var1 is not having any value. How can I do that? CREATE OR REPLACE…
user2488578
  • 896
  • 4
  • 21
  • 40
2
votes
1 answer

How to compare two rows (selected by defined conditions) across all column?

I have a data frame with many columns and rows, for example ID Group A B C D E F G … 1 1 0.1 0.0 0.5 0.0 0.9 0.0 0.0 … 2 1 0.1 0.0 0.0 0.7 0.0 0.0 0.3 … 3 2 0.0 0.1 0.6 0.0 0.0 0.2 0.0 … 1 1 0.0 0.0 0.0 0.0 0.0 0.0 0.0…
Bio_farmer
  • 149
  • 1
  • 7
2
votes
3 answers

Find Duplicates In Arrays

I am writing a method that would take the values and the array and find duplicates. If there are duplicates, like for instance two values have the same value, I will multiple that value by 2. If two values have the same value, I will multiple that…
2
votes
3 answers

Is there an R function to statistically compare different cluster solutions? (e.g. k-means solution with pam/clara solution)

I compared the silhouette widths of different cluster algorithms on the same dataset: k-means, clara and pam. I can see which one scores the highest on silhouette width. But can I now statistically test whether the solutions differ from each other…
2
votes
3 answers

Finding element pairs from two sets that have a predefined relation

I have two lists list1 = ['a', 'b', 'c', 'd'] list2 = ['e', 'f', 'g', 'h'] I know from before that some of these elements are related through another list ref_list = [ ['d', 'f'], ['a', 'e'], ['b', 'g'], ['c', 'f'], ['a', 'g'], ['a', 'f'],…
2
votes
3 answers

Should a custom comparer for strings allow for null values

I'm looking at someone elses code for a custom comparer that compares strings. I'm noticing that it will fall over if at least one of the string parameters is null. The compare returns -1, 0 or 1 based on the result of the comparison. Should code…
Coder 2
  • 4,761
  • 12
  • 40
  • 43
2
votes
4 answers

String comparison in 2 adjacent rows of a data frame in R

I have a data-frame with 627 observations and 16 variables are present. I am considering one column named "ZoneDivison" which has factors: North Eastern, Eastern and South Eastern. So, I want to compare the adjacent row values and create a new…
Ami
  • 197
  • 1
  • 12
2
votes
1 answer

kotlin "contains" doesn't work as expected

I am working with a method which filters the preferences which match with the ids, I am using the contains method, but even though the values are the same, the contains is showing a false in each iteration. The method looks like: private fun…
rasilvap
  • 1,771
  • 3
  • 31
  • 70
1 2 3
99
100